Q1.Write a program to display the following format using while loop:
-------------
a b
-------------
1 5
2 4
3 3
4 2
5 1
-------------
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=1,b=5;
cout<<"----------\n";
cout<<("a\tb\n");
cout<<"----------\n";
while(a<=5)
{
cout<<a<<"\t"<<b<<endl;
a++;
b--;
}
cout<<"----------\n";
getch();
}
Q2. Write a program to display the following format using while loop:
----------------
num sum
----------------
1 1
2 3
3 6
4 10
5 15
--------------
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num=1,sum=0;
cout<<"----------\n";
cout<<("num\tsum\n");
cout<<"----------\n";
while(num<=5)
{
sum=sum+num;
cout<<num<<"\t"<<sum<<"\n";
num++;
}
cout<<"----------\n";
getch();
}
Q3. Write a program that displays the sum of the following series using do-while loop.
1+1/4+1/8+......+1/100
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float c,r;
c=4.0;
r=1.0;
do
{
r=r+1.0/c;
c=c+4;
}
while(c<=100);
cout<<"Result is "<<r;
getch();
}
Q4.Write a program to display alphabets from A to Z using for loop...
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
for(ch='A';ch<='Z';ch++)
cout<<ch;
getch();
}
-------------
a b
-------------
1 5
2 4
3 3
4 2
5 1
-------------
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=1,b=5;
cout<<"----------\n";
cout<<("a\tb\n");
cout<<"----------\n";
while(a<=5)
{
cout<<a<<"\t"<<b<<endl;
a++;
b--;
}
cout<<"----------\n";
getch();
}
Q2. Write a program to display the following format using while loop:
----------------
num sum
----------------
1 1
2 3
3 6
4 10
5 15
--------------
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num=1,sum=0;
cout<<"----------\n";
cout<<("num\tsum\n");
cout<<"----------\n";
while(num<=5)
{
sum=sum+num;
cout<<num<<"\t"<<sum<<"\n";
num++;
}
cout<<"----------\n";
getch();
}
Q3. Write a program that displays the sum of the following series using do-while loop.
1+1/4+1/8+......+1/100
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float c,r;
c=4.0;
r=1.0;
do
{
r=r+1.0/c;
c=c+4;
}
while(c<=100);
cout<<"Result is "<<r;
getch();
}
Q4.Write a program to display alphabets from A to Z using for loop...
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
for(ch='A';ch<='Z';ch++)
cout<<ch;
getch();
}
Hello Bro Please Kindly Upload Other Looping Structure Program
ReplyDeleteI need program no 11
ReplyDeleteI need program no 11
ReplyDeleteya program mja b send kr da agr ap k pass abi save h to
DeleteKindly Upload Other Looping Structure Program
ReplyDeleteif you got others programs then plz send me
Deletepiease kindly other looping structure upload
ReplyDeleteplz upload full exercise
ReplyDeletei want full 52 questions pls
ReplyDeletesir i also want if you have kindly send me
Deletesir plz send ful ex program plz
ReplyDeletei need first 15 programs plz send me
ReplyDeleteI need while loop program of exercise
ReplyDelete