Professional Documents
Culture Documents
SL.
No.
1. WAP TO ENTER THREE NUMBERS AND PRING MAX
OF THEM
2. WAP TO MAKE MINI CALCULATOR
3. WAP TO FIND AREA OF
CIRCLE,TRIANGLE,RECTANGLE,SQUARE USING
DIFFERENT FUNCTION
4. WAP TO ENTER A CHARACTER,AND CHECK
WHETHER ENTERED CHARACTER IS
ALPHABET,DIGIT,SPACE,OR ANY SPECIAL
CHARACTER
5. WAP TO PROGRAM TO PRINT FIBONACII SERIES.
6. WAP TO FIND FACTORIAL OF GIVEN NUMBER.
7. WAP TO CHECK WHETHER GIVEN NUMBER IS
PALANDROM OR NOT
1
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n1,n2,n3,max;
if(n1>n2&&n1>n3)
cout<<"the maxe no. is"<<n1;
else if(n2>n1&&n2>n3)
cout<<"the max no. is"<<n2;
else
cout<<"the max no. is"<<n3;
getch();
}
.
Output :
2.
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int n1,n2,ch;
do
{
cout<<"\n1.Addition\n";
cout<<"\n2.Multiplication\n";
cout<<"\n3.Subtraction\n";
cout<<"\n4.Division\n";
cout<<"\n5.Exit\n";
cout<<"\nEnter your choice\n";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nEnter two numbers\n";
cin>>n1>>n2;
cout<<"\nThe Addition is\n"<<n1+n2;
break;
case 2:cout<<"\nEnter two numbers\n";
cin>>n1>>n2;
cout<<"\nThe Multiplication
is\n"<<n1*n2;
break;
case 3:cout<<"\nEnter two numbers\n";
cin>>n1>>n2;
cout<<"\nThe Subtraction is\n"<<n1-n2;
break;
case 4:cout<<"\nEnter two numbers\n";
cin>>n1>>n2;
cout<<"\nThe Division is\n"<<n1/n2;
break;
case 5:cout<<"\nPress any key\n";
getch();
exit(0);
break;
default:cout<<"\nEnter correct option\n";
break;
}
}while(ch!=5);
}
Output:
3.
include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,s,r,area;
int ch;
cout<<"\n1.Area of circle\n2.Area of Rectangle";
cout<<"\n3.Area of triangle\n4.area of
square\nEnter your choice:";
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"\nEnter radius of the circle:";
cin>>r;
area=3.14*r*r;
break;
}
case 2:
{
cout<<"\nEnter length and breadth:";
cin>>a>>b;
area=a*b;
break;
}
case 3:
{
cout<<"\nEnter two sides of the
triangle:";
cin>>a>>b;
area=1/2*a*b;
break;
}
case 4:
{
cout<<"\nenter the side of square";
cin>>a;
area=a*a;
break;
}
default: cout<<"\nWrong choice…!!!";
break;
}
cout<<"\nAreais"<<area;
getch();
}
Output:
4.
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
void main()
{
clrscr();
char ch;
if(isalpha(ch))
{
cout<<"the character is alphabet";
}
else if(isdigit(ch))
{
cout<<"the character is digit";
}
else if(isspace(ch))
{
cout<<"the character is space";
}
else
cout<<"the character is any other special
symbol";
getch();
}
Output:
5.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,f0=0,f1=1,n,f2;
cout<<"Enter the value of n= ";
cin>>n;
cout<<"The series is= "<<"\n";
cout<<f0<<"\t"<<f1;
n=n-2 ;
for(i=1;i<=n;i++)
{
f2=f0+f1;
cout<<"\t"<<f2;
f0=f1;
f1=f2;
}
getch();
}
Output:
6.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,fact=1,i;
cout<<"Entr the value of n= ";
cin>>n;
for(i=n;i>0;i--)
{
fact=fact*i;
}
getch();
}
Output:
7.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n1,n,rem,rev=0;
cout<<"enter a number to check wether the number is
palandrom or not";
cin>>n;
n1=n;
while(n1)
{
rem=n1%10;
rev=(rev*10)+rem;
n1=n1/10;
}
if(n==rev)
cout<<"the number is palandrom";
else
cout<<"the number is not a palandrom";
getch();
}
Output:
8.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int digit;
cout<<"Enter a digit\n";
cin>>digit;
switch(digit)
{
case 0 : cout<<"zero";
break;
case 1 : cout<<"one";
break;
case 2: cout<<"two";
break;
case 3: cout<<"three";
break;
case 4 : cout<<"four";
break;
case 5: cout<<"five";
break;
case 6 : cout<<"six";
break;
case 7 : cout<<"seven";
break;
case 8 : cout<<"eight";
break;
case 9: cout<<"nine";
break;
default: cout<<"enter correct choice";
}
getch();
}
Output:
9.
#include <iostream.h>
#include<conio.h>
void main ()
{
clrscr();
int n;
float sum=0;
int fact = 1;
cout<<"enter the no. terms";
cin>>n;
getch();
}
Output:
10.
#include<iostream.h>
#include<conio.h>
temp = A;
A = B;
B = temp;
cout<<"enter 2 numbers";
cin>>x>>y;
cout<<"Before swap"<<x<<'\t'<<y;
getch();
swap(x,y);
getch();
cout<<"\n Swap value in main call"<<x<<'\t'<<y;
getch();
}
Output:
11.
#include <iostream.h>
#include<conio.h>
#include <math.h>
long long convertOctalToBinary(int);
int main()
{
clrscr();
int octalNumber;
getch();
}
while(octalNumber != 0)
{
decimalNumber += (octalNumber%10) * pow(8,i);
++i;
octalNumber/=10;
}
i = 1;
while (decimalNumber != 0)
{
binaryNumber += (decimalNumber % 2) * i;
decimalNumber /= 2;
i *= 10;
}
return binaryNumber;
}
Output:
12.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
Output:
13.
#include <iostream.h>
#include<conio.h>
void decToBinary(int n)
{
int binaryNum[1000];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--)
cout << binaryNum[j];
}
void main()
{
clrscr();
int n;
cout<<"enter the digit";
cin>>n;
decToBinary(n);
getch();
}
Output:
14.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int i=0;
char binnum[100], hexdec[100];
cout<<"Enter any hexadecimal number : ";
cin>>hexdec;
cout<<"\nEquivalent Binary value is : ";
while(hexdec[i])
{
switch(hexdec[i])
{
case '0' : cout<<"0000";
break;
case '1' : cout<<"0001";
break;
case '2' : cout<<"0010";
break;
case '3' : cout<<"0011";
break;
case '4' : cout<<"0100";
break;
case '5' : cout<<"0101";
break;
case '6' : cout<<"0110";
break;
case '7' : cout<<"0111";
break;
case '8' : cout<<"1000";
break;
case '9' : cout<<"1001";
break;
case 'A' : cout<<"1010";
break;
case 'B' : cout<<"1011";
break;
case 'C' : cout<<"1100";
break;
case 'D' : cout<<"1101";
break;
case 'E' : cout<<"1110";
break;
case 'F' : cout<<"1111";
break;
case 'a' : cout<<"1010";
break;
case 'b' : cout<<"1011";
break;
case 'c' : cout<<"1100";
break;
case 'd' : cout<<"1101";
break;
case 'e' : cout<<"1110";
break;
case 'f' : cout<<"1111";
break;
default : cout<<"\nInvalid hexadecimal
digit "<<hexdec[i];
}
i++;
}
getch();
}
Output:
15.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int binnum, rem, quot;
int i=1, j, temp;
char hexdecnum[100];
cout<<"Enter Binary Number : ";
cin>>binnum;
quot = binnum;
while(quot!=0)
{
temp = quot % 16;
// To convert integer into character
if( temp < 10)
{
temp = temp + 48;
}
else
{
temp = temp + 55;
}
hexdecnum[i++]= temp;
quot = quot / 16;
}
cout<<"Equivalent hexadecimal value of "<<binnum<<"
is :\n";
for(j=i-1 ;j>0;j--)
{
cout<<hexdecnum[j];
}
getch();
}
Output:
16.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char string[10];
int c=0 ,i;
cout<<"enter a string";
gets(string);
for(i=0,c=0;string[i]!='\0';i++,c++)
{
c++;
}
Output:
17.
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[20];
int i;
cout<<"Enter the String : ";
cin>>str;
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=97 && str[i]<=122)
{
str[i]=str[i]-32;
}
}
cout<<"\nThe String in Uppercase = "<<str;
getch();
}
Output:
18.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char string1[10],string2[10],string3[20];
int i,j;
for(i=0,j=0;string1[i]!='\0';i++,j++)
{
string3[j]=string1[i];
}
for(i=0;string2[i]!='\0';i++,j++)
{
string3[j]=string2[i];
}
string3[j]='\0';
cout<<"the concintate string is";
puts(string3);
getch();
}
Output:
19.
#include<iostream.h>
#include<conio.h>
struct date
{
int dd;
int mm;
int yy;
};
date high(date[]);
void main()
{
clrscr();
int i;
date e[5],h ;
for(i=0;i<5;i++)
{
cout<<"\nenter employee info(joining date)\n";
cin>>e[i].dd;
cin>>e[i].mm;
cin>>e[i].yy;
}
h=high(e);
cout<<"\nthe senior most teacher is\n";
cout<<"\n"<<h.dd<<"\n"<<h.mm<<"\n"<<h.yy;
getch();
};
date high(date a[])
{
date temp,max ;
max=a[0];
int j;
for(j=0;j<5;j++)
{
if(a[j].yy<max.yy)
{
temp=a[j];
}
else if(a[j].mm<max.mm)
{
temp=a[j];
}
else if(a[j].dd<<max.dd)
{
temp=a[j];
}
}
return temp;
}
Output:
20.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct stud
{
int roll;
char name[10];
float m[3];
float tot;
}s[3];
void main()
{
clrscr();
int i,j;
cin>>s[i].roll;
gets(s[i].name);
for(j=0;j<3;j++)
{
cin>>s[i].m[j];
}
s[i].tot=s[i].m[0]+s[i].m[1]+s[i].m[2];
}
for(i=0;i<3;i++)
{
cout<<"\nroll"<<s[i].roll;
cout<<"\nName";
puts(s[i].name);
for(j=0;j<3;j++)
{
getch();
}
Output:
21.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int A[3][3],B[3][3],i,j,C[3][3],D[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>B[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
C[i][j]=A[i][j]+B[i][j];
}
}
getch();
}
Output:
22.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int M[3][3],i,j,sum=0;
void main()
{
clrscr();
int i,j,m[3][3],sum=0,k=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>m[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=i;j<3;j++)
{
if(j>i)
{
sum=sum+m[i][j];
}
else
{
k=k+m[i][j];
}
}
}
cout<<"\nSum of elements above the main diagonal
is\n"<<sum;
cout<<"\nSum of elements below the main diagonal
is\n"<<k;
getch();
}
Output:
24.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int M[3][3],i,j;
OUTPUT:
25
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],min,i;
Output:
26.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,m[3][3];
Output:
27.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*\t";
}
cout<<endl;
}
getch();
}
Output:
28.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"1\t";
}
cout<<endl;
}
getch();
}
Output:
29.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,j;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
{
cout<<i<<"\t";
}
cout<<endl;
}
getch();
}
Output:
30.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,j;
for(i=4;i>=1;i--)
{
for(j=1;j<=i;j++)
{
cout<<j<<"\t";
}
cout<<endl;
}
getch();
}
Output:
----------XXXXXX-----------