26. Write a Program to create for Multiple Choice Questions (MCQ).
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
int num;
clrscr();
cout<<"Who is the Prime Minister of India";
cout<<"\n 1. Manmohan Singh";
cout<<"\n 2. Narendra Modi";
cout<<"\n 3. Jawaharlal Nehru";
cout<<"\n 4. Sonia Gandhi";
cout<<endl<<"\n Enter the Correct Answer Serial Number:";
cin>>num;
if(num == 2)
{
cout<<"\n Correct Answer";
}
else
{
cout<<"\n Wrong Answer";
}
getch();
}
...................................................................................................................................................................
27. Write a Program to input a character check it is capital letter, small letter, digit or special character.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
char ch;
cout<<"Enter a Character";
cin>>ch;
if(ch>='A' && ch<='Z')
{
cout<<\n Capital Letter";
}
else if(ch>='a' && ch<='z')
{
cout<<"\n small letter";
}
else if(ch>='0' && ch<='9')
{
cout<<\n digit";
}
else
{
cout<<"\n Special Character";
}
getch();
}
OR
#include<iostream.h>
#include<conio.h>
Void main()
{
char ch;
cout<<"Enter a Character";
cin>>ch;
if(ch>=-65 && ch<=90)
{
cout<<"\n Capital Letter";
}
else if(ch>=97 && ch<=122)
{
cout<<"\n Small Letter";
}
else if(ch>=48 && ch<=57)
{
cout<<"\n Digit";
}
else
{
cout<<\n Special Character";
}
getch();
}
...................................................................................................................................................................
28. Write a Program to input a character and convert its case.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
cout<<"Enter a Character";
cin>>ch;
if(ch>=65 && ch<=90)
{
ch=ch+32;
cout<<"\n"<<ch;
}
else if(ch>=97 && ch<=122)
{
ch=ch-32;
cout<<"\n"<<ch;
}
getch();
}
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
int num;
clrscr();
cout<<"Who is the Prime Minister of India";
cout<<"\n 1. Manmohan Singh";
cout<<"\n 2. Narendra Modi";
cout<<"\n 3. Jawaharlal Nehru";
cout<<"\n 4. Sonia Gandhi";
cout<<endl<<"\n Enter the Correct Answer Serial Number:";
cin>>num;
if(num == 2)
{
cout<<"\n Correct Answer";
}
else
{
cout<<"\n Wrong Answer";
}
getch();
}
...................................................................................................................................................................
27. Write a Program to input a character check it is capital letter, small letter, digit or special character.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
char ch;
cout<<"Enter a Character";
cin>>ch;
if(ch>='A' && ch<='Z')
{
cout<<\n Capital Letter";
}
else if(ch>='a' && ch<='z')
{
cout<<"\n small letter";
}
else if(ch>='0' && ch<='9')
{
cout<<\n digit";
}
else
{
cout<<"\n Special Character";
}
getch();
}
OR
#include<iostream.h>
#include<conio.h>
Void main()
{
char ch;
cout<<"Enter a Character";
cin>>ch;
if(ch>=-65 && ch<=90)
{
cout<<"\n Capital Letter";
}
else if(ch>=97 && ch<=122)
{
cout<<"\n Small Letter";
}
else if(ch>=48 && ch<=57)
{
cout<<"\n Digit";
}
else
{
cout<<\n Special Character";
}
getch();
}
...................................................................................................................................................................
28. Write a Program to input a character and convert its case.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
cout<<"Enter a Character";
cin>>ch;
if(ch>=65 && ch<=90)
{
ch=ch+32;
cout<<"\n"<<ch;
}
else if(ch>=97 && ch<=122)
{
ch=ch-32;
cout<<"\n"<<ch;
}
getch();
}
...................................................................................................................................................................
29. Write a Program to input a three digit and print them ascending order.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c;
cout<<"Enter a,b,c";
cin>>a>>b>>c;
if(a<b && a<<c)
{
cout<<a<<" ";
if(b<c)
{
cout<<b<<c" "<<c;
}
else
{
cout<<c<<" "b;
}
getch();
}
else if(b<a && b<c)
{
cout<<b<<c";
if(a<c)
{
cout<<a<<c;
}
else
{
cout<<c<<a;
}
else if(c<a && c<b)
{
cout<<c<<" ";
if(a<b)
{
cout<<a<<b;
}
else
{
cout<<b<<a;
}
}
getch();
}
...................................................................................................................................................................
30. Write a Program for Print 100 to 1.
Answer :
#include<iostream.h>
#include<conio.h>
Void main()
{
int i;
for(i=100; i>=1;i--)
{
cout<<i<<"\n";
}
getch();
}
*********************************************************************************
0 comments:
Post a Comment