0% found this document useful (0 votes)
23 views

Hsslive Xi Comp App Unit Notes CH 4 To 7 Eng Act MLPM

Uploaded by

karthika vasu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Hsslive Xi Comp App Unit Notes CH 4 To 7 Eng Act MLPM

Uploaded by

karthika vasu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Join Telegram Channel: https://t.me/hsslive Downloaded from www.Hsslive.

in ®

Quick Notes on Plus One Computer Applications (Commerce) Page: 1

Chapter 4
Getting started with C++
C++ developed by Bjarne Stroustrup
Character set: Valid characters such as Letters, digits,special characters,white spaces & other characters

Keywords (reserved
words) - Eg: if, else, for, while, switch, break,void char, int, float,
Convey specific double,long etc
meaning to compiler
Identifiers - (user memory locations - variables Eg: num, sum1,
TOKENS defined names for Identifiers of statements - labels INT, my_score,
(fundamental program elements) functions - functions cin,
buildingblocks
Literals(Constants)- Integer literals (2, -15, +34)
/ lexical units)
Data that do not Floating literals (2.0, -24.5,152E+8 )
change value Character literals (‘a’,’2’,’+’,’\n’)
String literals (“a”, “abc”, “12ab”)
Punctuators-symbols # { , ; :
Operators - Arithmetic operators (+, -. *, /, %)
indicate a specific Relational operators (<,<=,>,>=, ==, !=)
operation Logical operators (&&, ||, ! )

Literals used to represent non-graphic symbols - escape sequences eg: ‘\n’, ‘\t’

Rules for naming identifiers 1. Use only letters (upper&lower), digits and underscore (_)
2. Don’t use keywords.
3. Don’t start with digit
IDE – Integrated Development Environment (provides facilities for typing, editing, searching, compiling,
linking and executing a program)
Extension for C++ program in Geany-> .cpp

Chapter 5
Datatypes and Operators
Data types: means to identify the nature of data and performable operations .

Fundamental datatypes:
Datatype Type of value Memory (bytes) Eg:
void null or empty data 0
char character values 1 ‘A’, ‘\n’ Integral
datatypes
int integer values 4 84, -4 Numerical
datatypes
float real values 4 Floating
5.6, -89.5 point
double Real values(more 8 datatypes
precision than float)
Aspects of a variable
int Num=18;

L value – 1001 R value – 18, Variable – Num


Join Telegram Channel: https://t.me/hsslive Downloaded from www.Hsslive.in ®

Quick Notes on Plus One Computer Applications (Commerce) Page: 2

Unary (1 operand) ++, --, unary +, unary -, !


ds Binary (2 operands) +, -, *
oper an In the expression
f Ternary (3 operands) ?:
N o. o a+b
Operators
+ ->operator
Nat a,b -> operands.
ure Arithmetic(+, -, *, /, % )
Relational (<, <=, >, >=, ==, !=)
Logical(&&, ||, !)

x y x+y x-y x*y x/y x%y


10 4 21 2 1(remainder)
x<y x>y x<=y x>=y x==y
7 3
0 1 0 1 0
(x<y)&&(y>2) (x<y) || (y>2) (x<y) &&(y>5) (x<y) || (y>5) !(x<y)
0 && 1 -> 0 0 || 1 -> 1 0 && 0 -> 0 0 || 0 -> 0 !0 -> 1

Input operator extraction(get from) : >> eg: cin>>a;


Output operator insertion (put to) : << eg: cout<<a;
Assignment operator : = eg: a=b; (value in b given to a)

Integer expression –only integer operands


Arithmetic Floating(real) – only real operands
Expresssion:
combination of operator and operands Constant expression – only constant values
eg: a+b; Relational Uses relational operators a<b
Logical Uses logical operators !(a<b)

Type of Use Example


statement
Statement: Declaration Tells compiler about the type of int roll; float avg;
Smallest executable unit data
(ends with the
symbol ; ) Assignment To assign value to a variable a=5; sum=a+b;
Input To input data cin>>a;
Output To output data cout<< num;

Cascading of I/O operators : >> or << more than once in a statement. eg: cin>>a>>b; / cout<<a<<b;
Difference between = and == operators.
= ==
Assignment operator Relational operator
Assigns value to a variable Compares values

Chapter 6
Introduction to Programming
Preprocessor directive - # - directives to compiler to process the info provided before actual
compilation.
Header files –supports C++ programs and are kept in the standard library eg: iostream
Join Telegram Channel: https://t.me/hsslive Downloaded from www.Hsslive.in ®

Quick Notes on Plus One Computer Applications (Commerce) Page: 3

Most important function in a C++ program – main() - program execution starts and ends within
main().
Comments – Internal documentation, helps future modification of the program
(a) Single line - // (b) Multiline - /* .... */
Variable initialisation : Supplying value to variable at the time of declaration
eg: int a=5;
Dynamic initialisation : Initialising a variable during execution.
eg: int sum=a+b;

Access modifier - const


(to create symbolic constants whose value never changes during execution.
Type modifiers - signed, unsigned, long, short
( to change the size, range or precision of data types)

Increment / Decrement - ++ / -- --> a++ (post increment) ++a (preincrement)


(A post-form denotes use, then change method and a pre-form denotes change, then use method)

int m=5; int m=5;


n=m++; n=--m;
(Now n -> 5 and m -> 6) (Now n -> 4 and m -> 4)

Precedence of operators : Order of execution of operation in an expression.


Arithmetic assignment operators : +=, -=, *=, /=, %=
(C++ shorthands) eg : a=a+5; is same as a+=5;

Implicit – Done by compiler – low to high(type promotion) – 5/2.0 -> 2.5


Type Conversion
(conversion of one
datatype to another)

Explicit – Done by User – low to high/high to low(type casting) – 5/(int)2.0 -> 2


C++ statements to increment the value of a by 1-> a=a+1; a+=1; a++; ++a;
C++ program to find the sum of two numbers
#include <iostream>
using namespace std;
int main()
{
int num1, num2, sum;
cout<<"Enter two numbers: ";
cin>>num1>>num2;
sum=num1+num2;
cout<<"Sum of the entered numbers = "<<sum;
}

Chapter 7
Control Statements
(i) decision/selection statements (if, if else, switch)
Control Statements (statements are selected for execution based on a decision)
(to change normal flow of
program execution)
(ii) iteration(loop) statements (for, while, do while)
Join Telegram Channel: https://t.me/hsslive Downloaded from www.Hsslive.in ®

Quick Notes on Plus One Computer Applications (Commerce) Page: 4

if else if ladder <---> switch

1. if (code ==2) cout<<”Binary”; switch(code)


else if (code==8) cout<<”Octal”; { case 2: cout<<”Binary”; break;
else if(code==16) cout<<”Hexadecimal”; case 8: cout<<”Octal”; break;
else cout<<”Wrong code”; case 16 : cout<<”Hexadecimal”; break;
default: cout<<”Wrong code”;
}
switch if else if ladder
Permits multiple branching. Permits multiple branching.
only for checking equality Check any relational /logical condition
Case constant is integer/character Can compare against a set of values
Uses default when nothing matches, break is used to exit. When no condition is true, else block
executes.

The conditional operator (? :)


Syntax: Test expression ? True_case code : False_case code;

if (score>18) cout<<”pass” ; (score>18) ? cout<<”pass”: cout<<”fail”;


else cout<<”fail”;

Loop components – (1) initialisation - statement that gives starting value to loop variable(i=1)
(2) condition – the test expression. (i<=10)
(3) updation – statement that changes the value in loop variable (i++)
(4) body of loop- set of statements to execute repeatedly (cout<<i;)

for loop while loop do while loop

for (i=1;i<=10;i++) i=1; i=1;


{ cout << i; } while(i<=10) do
{cout<<i; {cout<<i;
i++; } i++;
}while(i<=10);
 Here, i is the loop variable (its value controls the loop)
 All these loops give the same output: 12345678910

Entry controlled loop Exit controlled loop


1. condition before loop body 1. condition after loop body
2. will run only if condition true 2. will run at least once even if condition is true/false
eg: for, while eg: do while

Warm Regards: Liju Mathew MTHSS Chungathara, Priya MD GHSS Purathur,Jessie Mathew GHSS Vaniyambalam

You might also like