You are on page 1of 9

WAP of Palindrome

#include<iostream>

#include<conio.h>

using namespace std;

int palin(int);

int main()

int num, res;

cout<<"Enter any number to check Palindrome or Not: ";

cin>>num;

res=palin(num);

if(num==res)

cout<<"Number is Palindrome: "<<res;

else

cout<<"Number is not a Palindrome: "<<res;

getch();

return 0;

int palin(int n)

int digit, result=0;

do

digit=n%10;
result=(result*10)+digit;

n=n/10;

}while(n!=0);

return (result);

WAP of SUM of Diagonl Matrix


#include<iostream>

#include<conio.h>

using namespace std;

int main()

int A[3][3];

cout<<"Enter the Matrix: ";

for(int i=0; i<3; i++)

for(int j=0; j<3; j++)

cin>>A[i][j];

for(int i=0; i<3; i++)

{
for(int j=0; j<3; j++)

if(i==j)

cout<<"Primary Diagonal is: "<<A[i][j]<<endl;

for(int i=0; i<3; i++)

for(int j=0; j<3; j++)

if(i+j==3-1)

cout<<"Secondary Diagonal is: "<<A[i][j]<<"\t"<<endl;

cout<<"\n";

getch();

return 0;

WAP OF Factorial number


#include<iostream>

#include<conio.h>

using namespace std;

int main()
{

int i, num, fact=1;

cout<<"Enter the Number: ";

cin>>num;

for(i=1; i<=num; i++)

fact=fact*i;

cout<<"Factorial of"<<num<<"is: "<<fact;

getch();

return 0;

WAP OF CALCULATOR BY SWITCH CASE (Page-216... 10.3)

#include<iostream>

#include<conio.h>

using namespace std;

int main()

int a,b;

float res;

char ch;

cout<<"Enter two number: ";

cin>>a>>b;
cout<<"\nEnter the Operator(+,-,*,/): "<<

cin>>ch;

switch(ch)

case'+': res=a+b;

cout<<"Result: "<<res;

break;

case'-': res=a-b;

cout<<"Result: "<<res;

break;

case'*': res=a*b;

cout<<"Result: "<<res;

break;

case'/': res=a/b;

cout<<"Result: "<<res;

break;

getch();

return 0;

WAP TO PRINT LARGEST OF THREE (page-214)

#include<iostream>

#include<conio.h>
using namespace std;

int main()

int a, b, c, max;

cout<<"Enter three number: ";

cin>>a>>b>>c;

max=a;

if(y>max)

max=y;

if(z>max)

max=z;

cout<<"\nThe Largest of"<<a<<","<<b<<"and"<<c<<"is: "<<max;

getch();

return 0;

WAP TO PRINT SUM OF DIGIT

#include<iostream>

#include<conio.h>

using namespace std;

int main()

long num, digit, temp, sum=0;

cout<<"Enter the Digit: ";

cin>>num;
while(num>0)

digit=num%10;

sum=sum+digit;

num=num/10;

cout<<"Sum of Digit"<<num<<"is: "<<sum;

getch();

return 0;

WAP to PRINT PATTERN ###

#include<iostream>

#include<conio.h>

using namespace std;

int main()

int i, j, rows;

cout<<"Enter rows: ";

cin>>rows;

for(i=1; i<=rows; i++)

for(j=1; j<=i; j++)

cout<<"#";
}

cout<<"\n";

getch();

return 0;

WAP (Page-316 Q.25)

#include<iostream>

#include<ctype.h>

#include<conio.h>

using namespace std;

int main()

char ch;

int a;

cout<<”Enter the character: “;

cin>>ch;

a=ch;

if(isalnum(a))

cout<<”\nAlphanumeric character”;

if(isdigit(a))

cout<<”\nAnd Digit Character”;

else if(isalpha(a))

cout<<”\nAnd Alphabetic Character”;


}

else

cout<<”\nOther character”;

getch();

return 0;

You might also like