C++ Basic Syntax

C++ Basic Syntax :-


void main()
int a,b,c;
cout<<"Enter the value of a and b is"<<endl; cin>>a;
cout<<"The sum of a and b is "<<c;

Result of C++ Basic Syntax :-

C++ Examples


cout :-

To display data on screen, we use the ‘cout’ keyword followed by insertion operator. Example :- cout<<a; We can display many item in one ‘cout<<‘ statement Example :- int a=10; cout<<“The value of a is :”<<a<<endl; endl:- it is use to indicate the end of line. Example :- int a=10,b=20; cout<<“The value of a is “<< a <<endl <<“The value of b is “<< b <<endl; Result :- The value of a is :10 The Value of b is :20


Cin :-

When, we want to input data from the keyboad, we use ‘cin’ followed by ‘extraction(>>)’ Operator. Example : – int a; cin>>a; We can input a series of item from the keyboard. int a,b; cin >> a >> b;

Follow Us

Contact Us


Back to Top