Practice Problems
Example 1: Write a program to display A,C,E to Z ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
char i;
i='A';
While(i<='Z')π condition
{
Cout<<i<<endl;
i++;
}
getch() ;
}
Example 2: Write a program to display 1,4,3,16 to 100 ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,r;
i=1;
While(i<=10)π condition
{
if(i%2==0)
{
r=i*i;
}
else
{
r=i;
}
Cout<<r<<endl;
i++;
}
getch() ;
}
Example 3: Write a program to display 1,2,9,4,25to 10 ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,r;
i=1;
While(i<=10)π condition
{
if(i%2==0)
{
r=i;
}
else
{
r=i*i;
}
Cout<<r<<endl;
i++;
}
getch() ;
}
Example 4: Write a program to display 1 to n ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
i=1;
cout<<"enter value for n ";
cin>>n;
While(i<=n)π condition
{
Cout<<i<<endl;
i++;
}
getch() ;
}
Example 5: Write a program to display 5 to n ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
i=5;
cout<<"enter value for n ";
cin>>n;
While(i<=n)π condition
{
Cout<<i<<endl;
i++;
}
getch() ;
}
Example 6: Write a program to display n to 1 ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
cout<<"enter value for n ";
cin>>n;
i=n;
While(i>=1)π condition
{
Cout<<i<<endl;
i--;
}
getch() ;
}
Example 7: Write a program to display even numbr between n to 1 ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
cout<<"enter value for n ";
cin>>n;
i=n
While(n>=1)π condition
if(n%2==0)
{
cout<<n<<endl;
}
n--;
}
getch() ;
}
Example 8: Write a program to display 2,16,6,64 to n ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
i=1,j=2;
cout<<"enter value for n ";
cin>>n;
While(j<=n)π condition
{
if(i%2==0)
{
cout<<j*j<<endl;
}
else
{
cout<<j<<endl;
}
i++;
j+=2;
}
getch() ;
}
Example 9: Write a program to display 1,4,9,16 to n ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
i=1;
cout<<"enter value for n ";
cin>>n;
While(i<=n)π condition
{
Cout<<i*i<<endl;
i++;
}
getch() ;
}
Example 10: Write a program to display 1,9,25 to n ??
Answer : #include <iostream.h>
#include <conio.h>
void main()
{
Clrscr();
int i,n;
i=1;
cout<<"enter value for n ";
cin>>n;
While(i<=n)π condition
{
if(!(i%2==0)
{
cout<<i*i<<endl;
}
i+=2;
}
getch() ;
}
π
IF you want to know how to display any string or anything in C++ then CLICK HERE
π IF you want to know How to solve Complex type of mathematical Problem in C++
π IF you want to know How to calculate percentage in C++ Programming CLICK HERE
π IF you want to know How to use mathematical operator in c++ CLICK HERE
π what is shortend operators and how to use it in program CLICK HERE what
Our website:
π https://codemasternisha.blogspot.com/π
if you face any any problem or any issue about our website then fill the contact us page and write your issues in it ...
πππππππππππππ
KEEP SUPPORTING π !! KEEP LEARNING π !!
πππππππ
0 Comments