There are two types of
streams :
(i) Input Stream
(ii) Output Stream
(i) Input Stream :
The stream which produces information is known as the
Input Stream and it is connected to the standard input device , that is , Keyboard.
cin which is an
object of the istream class and it is used to implement the input stream .
(ii) Output Stream
The stream which consumes information is known as the
output stream and it is connceted to the standard output device, that is , monitor.
cout which is an
object of the ostream and it is used to implement the output stream.
>> is known as the
extraction operator and it is used to extract the information from the input
stream.
<< is known as the
insertion operator and it is used to insert the information into the output
stream.
endl is used to display the
information on the newline.
Conditional statements:-
Q . WAP to read the year
and check whether the year is leap or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int year;
clrscr();
cout<<endl<<"Enter the year :";
cin>>year;
if((year%4==0&&year%100!=0)||(year%400==0))
cout<<endl<<"Leap
Year.";
else
cout<<endl<<"Not a Leap
Year.";
getch();
}
Q .WAp to read the three
numbers and find the second maximum of the three numbers
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c,max,smax;
clrscr();
cout<<endl<<"Enter the value of a,b and
c:";
cin>>a>>b>>c;
if(a>b)
{
max=a;
smax=b;
}
else
{
max=b;
smax=a;
}
if(c>max)
{
smax=max;
max=c;
}
else if(c>smax)
smax=c;
cout<<endl<<"Second Maximum = "
<<smax;
getch();
}
All program done in c now
write in C++
1)
if else
2)
for loop
3)
while loop
4)
do while loop
5)
Arrays
No comments:
Post a Comment