
CHAPTER 6-GETTING STARTED WITH
-
C++ was developed by Bjarne Struostrup in early 1980's.
-
C++ provides following tokens (smallest individual unit in
-
a program:
-
Key words , identifiers , literals,punctuators,operators
-
Keyword is a word carrying special meaning and purpose
-
Identifiers are the user defined names for different parts
-
of the program .In c++ , an identifier may contain
-
letters(a--z,A--Z) digits(0--9) and a symbol underscore(_)
-
Literals are items that never change their value during
-
a program run
-
C++ allows following literals:
-
integer constant
-
character constant
-
floating constant
-
string literal
-
-
The multiple use of input or output (">>"or"<<")
-
in a statement is called cascading of I/O operators.
-
ERRORS
SYNTAX ERROS
Syntax errors occur when rules of a programming language are misused ie ,
when a grammatical rule of C++ Is violated .
For instance
main( )
{
int a,b :
cin>>a>>b;
cout<<a+b;
return 0
}
RUN TIME ERRORS (Execution errros)
A run time error is that occurs during
the execution of a program.It is caused of some illegal operation taking place or inavailability of desired or required conditions for the execution of the program.
For instance,if a program is trying to open a file which does not exist or it could not be opened,it results into an execution error .Similarly ,if enough memory is not available or an expression is trying to divide a number by zero are run time errors
LOGICAL ERRORS
A logical error is that error which causes a program to produce incorrect or undesired output .
For instance ,if we are trying to print the table of a number 3 and if we say
ctr=1;
while (ctr>10)
{
cout<<n*ctr;
ctr=ctr+1;
}
SEMANTIS ERROR
Semantic errors occur when statements are not meaningful .Semantics refers to the set of rules which give the meaning of a statement .
For instance ,the statement 'Sita plays guitar ' is syntactically and semantically correct as it has some meaning but the statement 'Guitar plays Sita ' is synntactically correct (syntax is correct)
but semantically incorrect .Similarly, there are sementics rules of a programming language ,violation of which results in semantical errors.
TYPE ERRORS
Data in C++ has an associated data type The value 7,for instance ,is an integer.'a' is a character contant whereas "hi" is a string .If a function is given wrong type of data ,type error is signalled by the compiler.
For instance ,if the integer argument
was expected but actually string was given in place of it,it is a type error.




