C++ Programming Tutorials

C++ Programming Tutorials

C++ Programming Tutorials



 
 

C++ Programming Tutorials



     C++ is developed by Bjarne Stroupsoup at 1979 at Bell Labouraties in USA.
C++ is a high level language.
iostream - input and output stream
conio - console input and output
cout - console input
cin - console ouput
<< - inseration operator
>> - Extraction operator

Manipulators
1. cout.width
2. cout.fill
3. cout.precision
4. set w
5. set fill
6. set precision

cout.width program

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout.width(30);
cout<<"kumar"<<endl;
cout.width(70);
cout<<"selva"<<endl;
getch();

}

Cout.fill program

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout.width(30);
cout.fill('&');
cout<<"arun"<<endl;
cout.width(50);
cout.fill('*');
cout<<"kumar"<<endl;
cout.width(70);
cout.fill('#');
cout<<"selva"<<endl;
getch();
}

cout.precision program

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout.width(30);
cout.fill('&');
cout.precision(2);
cout<<12.77777<<endl;
cout.width(50);
cout.fill('*');
cout.precision(3);
cout<<24.473444<<endl;
cout.width(70);
cout.fill('#');
cout.precision(4);
cout<<34.7778<<endl;
getch();
}

set w, set fill,set precision program

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
cout<<set w(30)<<set fill('*')<<"arun"<<endl;
cout<<setw(50)<<setfill('$')<<endl;
cout<<setw(50)<<setfill('$')<<setprecision(2)<<12.44<<endl;
getch();
}

if and else statement program

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a;
clrscr();
cout<<"Enter the value of a is :"<<endl;
cin>>a;
if(a>=18)
cout<<"I am eligible for vote"<<endl;
else
cout<<"I am not eligible for vote"<<endl;
getch();
}

if else if program

#include<iostream.h>
#include<conio.h>
#include<iomainp.h>
void main()
{
int a,b,c;
clrscr();
cout<<"Enter the value of a,b,c ";
cin>>a>>b>>c;
if((a>b)&&(a>c))
cout<<"a is greater";
else if((b>a)&&(b>c))
cout<<"b is greater";
else
cout<<"c is greater";
getch();
}

Switch program

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a;
clrscr();
cout<<"Enter the value of a is";
cin>>a;
switch(a)
{
case 1:
{
int b,c,d;
cout<<"Enter the value of b and c is";
cin>>b>>c;
d=b+c;
cout<<"The value of d is"<<d<<endl;
break;
}
case 2:
{
int b,c,d;
cout<<"Enter the value of b and c is:";
cin>>b>>c;
d=b-c;
cout<<"The value of d is"<<d<<endl;
break;
}
case 3:
{
int b,c,d;
cout<<"Enter the value of b and c is";
cin>>b>>c;
d=b*c;
cout<<"The value of d is"<<d<<endl;
break;
}
case 4:
{
int b,c,d;
cout<<"Enter the value of b and c is";
cin>>b>>c;
d=b/c;
cout<<"The value of d is"<<d<<endl;
break;
}
default :
{
cout<<"you are enter the wrong number";
break;
}
}
getch();

}

Post a Comment

0 Comments