You are on page 1of 43

Title

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

8. WAP TO ENTER A DIGIT AND PRINT IT IN WORDS


9.
WAP TO PRINT SUM OF SEQUENCE
10. WAP TO SWAP TWO VALUE USING CALL BY
REFERNCE.

11. WAP A PROGAM TO CONVERT OCTAL NUMBER IN


BINARY NUMBER.

12. WAP A PROGAM TO CONVERT BINARY NUMBER IN


DECIMAL NUMBER

13. WAP A PROGAM TO CONVERT DECIMAL NUMBER IN


BINARY NUMBER

14. WAP A PROGAM TO CONVERT HEXADECIMAL


NUMBER IN BINARY NUMBER

15. WAP A PROGAM TO CONVERT BINARY NUMBER IN


HEXADECIMAL NUMBER
16. WAP TO TO ENTER A STRING AND FIND ITS
LENGTH.

17. WAP TO ENTER A STRING IN LOWER AND CONVERT


IT TO UPPER .

18. WAP TO APEND TWO STRING.

19. DEFINE A STRUCTURE DATE WITH DD.MM.YY.WAP


TO READ JOINING DATE OF 5 EMPLOYEE.WRITE A
FUNCTION WHO WILL ACCEPT THESE 5 DATE AND
WHICH WILL RETURN SENIOR MOST EMPLOYINING
DATE.
20. DEFINE STRUCT STUDENT WITH
ROLL,NAME,MARKS OF 3 SUBJECTS & TOTAL.WAP
TO READ DETAIL OF 3 STUDENTS.

21. WAP TO ENTER 2 MATRIX AND ADDITION OF THEM


AND SUBRACTION OF MATRIX
22. WAP TO FIND ROW SUM & COLUMN SUM OF
MATRIX.
23. WAP TO SUM THE ELEMENTS ABOVE AND BELOW
THE MAIN DIAGONAL.

24. WAP A PROGRAM TO TRANSPOSE A MATRIX.

25. WAP PROGRAM TO PRINT SMALLEST ELEMENT OF


AN ONE-D ARRAY.

26. WAP TO PRINT UPPER HALF AND LOWER HALF OF


THE ARRAY.

27. WAP TO PRINT


*
**
***

28. WAP TO PRINT


1
11
111

29. WAP TO PRINT


333
22
1

30. WAP TO PRINT


123
12
1

1
#include<iostream.h>
#include<conio.h>

void main()

{
clrscr();

int n1,n2,n3,max;

cout<<"enter the three no.";


cin>>n1>>n2>>n3;

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;

cout<<"enter the character";


cin>>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;
}

cout<<"Factorial of the number= "<<fact;

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;

for (int i = 1; i <= n-1; i++)


{
fact *= i;
sum += 1.0/fact;
}
cout<<"sum "<<sum+1;
cout<<endl;

getch();
}

Output:

10.

#include<iostream.h>
#include<conio.h>

void swap(int &A,int &B)


{
int temp;
cout<<"\nSwapped value in function before
swap"<<A<<'\t'<<B;

temp = A;
A = B;
B = temp;

cout<<"the value after swap is"<<A<<'\t'<<B;


}
void main()
{
Clrscr();
int x,y;

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;

cout << "Enter an octal number: ";


cin >> octalNumber;

cout << octalNumber << " in octal = " <<


convertOctalToBinary(octalNumber) << "in binary";

getch();
}

long long convertOctalToBinary(int octalNumber)


{
int decimalNumber = 0, i = 0;
long long binaryNumber = 0;

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();

long bin, dec = 0, rem, num, base = 1;

cout << "Enter the binary number(1s and 0s) : ";


cin >> num;
bin = num;
while (num > 0)
{
rem = num % 10;
dec = dec + rem * base;
base = base * 2; num = num / 10;
}
cout << "The decimal equivalent of " << bin << " :
" << dec << endl; getch();
}

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++;
}

cout<<"the length of the string is"<<c/2;


getch();
}

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;

cout<<"Enter the first string";


gets(string1);
cout<<"Enter secong string";
gets(string2);

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;

cout<<"Enter info of 3 students(roll,name,marks of


3 subjects)";
for(i=0;i<3;i++)
{

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];
}

cout<<"the result is";

for(i=0;i<3;i++)
{
cout<<"\nroll"<<s[i].roll;
cout<<"\nName";
puts(s[i].name);
for(j=0;j<3;j++)
{

cout<<"the marks is"<<s[i].m[j]<<'\n';


}

cout<<"\ntotal marks is:"<<s[i].tot;


}

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];

cout<<"enter first matrix\n";


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>A[i][j];
}
}

cout<<"enter second matrix\n";

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];
}
}

cout<<"sum of matrix is\n";


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<C[i][j];
}cout<<endl;
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
D[i][j]=A[i][j]-B[i][j];
}
}
cout<<"subtraction of matrix is\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<D[i][j]<<'\t';
}cout<<endl;
}

getch();
}

Output:
22.

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int M[3][3],i,j,sum=0;

cout<<"enter a matrix of 3x3";


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>M[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0,sum=0;j<3;j++)
{
sum=sum+M[i][j];
}
cout<<"\nThe sum of row of
row"<<i+1<<"is"<<sum;
}
for(i=0;i<3;i++)
{
for(j=0,sum=0;j<3;j++)
{
sum=sum+M[j][i];
}
cout<<"\nThe sum of row"<<i+1<<"is"<<sum;
}
getch();
}
Output:
23.
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int i,j,m[3][3],sum=0,k=0;

cout<<"Enter the matrix elements\n";

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;

cout<<"enter a matrix of size 3x3\n";


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>M[i][j];
}
}
cout<<"the transpose matrix is\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<M[j][i]<<” “;
}
cout<<endl;
}
getch();
}

OUTPUT:
25
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a[10],min,i;

cout<<"Enter 10 numbers to find smallest element of


them\n";
for(i=0;i<10;i++)
{
cin>>a[i];
}
min=a[0];
for(i=0;i<10;i++)
{
if(min>a[i])
{
min=a[i];
}
}
cout<<"The smallest element is\n"<<min;
getch();
}

Output:
26.
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,j,m[3][3];

cout<<"Enter the matrix elements\n";


for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>m[i][j];
}
}
cout<<"The upper half elements are\n";
for(i=0;i<3;i++)
{
for(j=i;j<3;j++)
{
cout<<m[i][j]<<'\t';
}cout<<endl;
}
cout<<"\nThe lower half elements are\n";
for(i=0;i<3;i++)
{
for(j=i;j<3;j++)
{
cout<<m[j][i]<<'\t';
} cout<<endl;
}
getch();
}

Output:
27.
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,n,j;

cout<<"enter numbers of lines";


cin>>n;

cout<<"the patter is\n";

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;

cout<<"enter numbers of lines";


cin>>n;

cout<<"the patter is\n";

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;

cout<<"enter numbers of lines";


cin>>n;

cout<<"the patter is\n";

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;

cout<<"enter numbers of lines";


cin>>n;

cout<<"the patter is\n";

for(i=4;i>=1;i--)
{
for(j=1;j<=i;j++)
{
cout<<j<<"\t";
}
cout<<endl;
}
getch();
}

Output:

----------XXXXXX-----------

You might also like