The C Command Symbols
The C Command Symbols
.comments
: The following comment is allowed
-: Output operators
The statement
;"Cout<<"C++ is better then C
causes the string in quotation marks to be displayed on the screen. The identifier cout
is a predefined object the represents the standard O/P stream in C++ . Here,the
.standard O/P stream in C++ represents the screen
.The operator << is called the insertion or put to operation
>include<iostream.h#
) (Main
{
; Float number1 , number2 , sum , avg
;Cout<<"enter 2 nos = " //prompt
Cin>>number1; / /read numbers
Cin>>number2;// from keyboard
;Sum = number1+number2
; Avg = sum/2
; "Cout<<"sum = "<<sum<<"\n
;Cout<<"average = "<<avg
}
Input operators
: The statement
; Cin>>number1
Is an i/p statement and causes the program to wait for the user to type in a no . the
number keyed in is placed in the variable number1. the identifier cin is a predefined
object in c++ that corresponds to the standard i/p stream . here , this stream represent
. the keyboard
. WAP to find area and circumference of a circle . 3
>include<iostream.h#
>include<conio.h#
) (Void main
{
;) (Clrscr
; Float r , area , circum
;" Cout<<"enter radius of circle
; Cin>>r
; Area = 3.14 *r * r
; Cout<<"\n area = "<<area
; Circum =2 * 3.14 * r
; Cout<<"circumference = "<<circum
}
>include<iostream.h#
>include<conio.h#
) (Void main
{
;) (Clrscr
; Float l , w , area, peri
: Cout<<"enter length and width of rect
Cin >>l >>w ; // aceepting length and width of a rect
;Area = l*w
; Peri = 2 * (l*w)
; Cout<<"\n area = "<<area<<" \n perimeter = "<<perimeter
}
>include<iostream.h#
>include<conio.h#
) (Void main
{
; ) ( Clrscr
; Float cen , faren
;" Cout<<"input temp in centigrade
; Cin >>cen
; Faren =1.8*cen +32
; Cout<<"\n equivalent farenheit temp is : "<<faren
}
Structure of a program
The smallest individual units in a program are known as tokens . C++ has the foll
-: tokens
Keywords . 1
Identifiers . 2
Constants .3
Strings .4
Operators .5
-: Keywords . 1
The keywords implement specific c++ language features .They are explicitly
reserved identifiers and cannot be used as names for the program variables or other
. user-defined program elements
Identifiers . 2
Identifiers refer to the names of variables, functions, arrays, classes, etc created
by the programmer. They are the fundamental requirement of any language. Each
.language has its own rules for naming these identifiers
++The foll rules are common to both C and C
Symbolic Constants . 3
++Operators in C . 4
Data encapsulation .1
Data hiding and access mechanism .2
Automatic initialization and clear up of objects .3
Operator overloading .4
Languages that support programming with objects are said to be object based
.programming languages. They do not support inheritance and dynamic binding
.Ada is a typical object-based programming language
.The language that support features include C++, small talk and object pascal