Today i am starting a series of programs of loops. Now i wish that i would be regularly updating this blog so that all of my followers can be benefitted. thanks in believing in me
//WRITE A PROGRAM TO DISPLAY 1 TO 10 USING WHILE LOOP
#include<iostream.h>
#include<conio.h
void main()
{
int i=1;
while(i<=10)
{
cout<<i<<endl;
i++;
}
getch();
}
//WRITE A PROGRAM TO DISPLAY FIRST 10 EVEN NUMBERS USING WHILE LOOP
#include<iostream.h>
#include<conio.h>
void main()
{
int i=2;
while(i<=20)
{
cout<<i<<endl;
i=i+2;
}
getch();
}
//WRITE A PROGRAM TO DISPLAY THE SUM OF 1 TO 10 USING WHILE LOOP
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i=1,sum=0;
while(i<=10)
{
sum=sum+i;
i++;
}
cout<<"The sum of 1 to 10 is "<<sum;
getch();
}
//WRITE A PROGRAM TO DISPLAY 1 TO 10 USING WHILE LOOP
#include<iostream.h>
#include<conio.h
void main()
{
int i=1;
while(i<=10)
{
cout<<i<<endl;
i++;
}
getch();
}
//WRITE A PROGRAM TO DISPLAY FIRST 10 EVEN NUMBERS USING WHILE LOOP
#include<iostream.h>
#include<conio.h>
void main()
{
int i=2;
while(i<=20)
{
cout<<i<<endl;
i=i+2;
}
getch();
}
//WRITE A PROGRAM TO DISPLAY THE SUM OF 1 TO 10 USING WHILE LOOP
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i=1,sum=0;
while(i<=10)
{
sum=sum+i;
i++;
}
cout<<"The sum of 1 to 10 is "<<sum;
getch();
}
No comments:
Post a Comment