Hsslive Xi Comp App Unit Notes CH 4 To 7 Eng Act MLPM
Hsslive Xi Comp App Unit Notes CH 4 To 7 Eng Act MLPM
in ®
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;
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 ®
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;
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 ®
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;)
Warm Regards: Liju Mathew MTHSS Chungathara, Priya MD GHSS Purathur,Jessie Mathew GHSS Vaniyambalam