You are on page 1of 4

Write a program will tell us that the entered numbers are a palindrome

or not .
i.e civic
1234321
============================================
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
void main()
{
clrscr();

char c1,c2,c3,c4,c5,c6;
long int no;
int op1,op2;

cout<<"\n\n1-Alphabet Palindrome\n\n2-Integer
Palindrome";
cout<<"\n\nEnter Option: ";
cin>>op1;

switch (op1)
{
case 1:
{
clrscr();

cout<<"\n\n1-Five Character Alphabet\n\n2-Six


Character Alphabet";
cout<<"\n\nEnter Option: ";
cin>>op2;

switch (op2)
{
case 1:
{
clrscr();
cout<<"\n\nEnter Five Characters Alphabet: ";
cin>>c1>>c2>>c3>>c4>>c5;

if (c5==c1&&c4==c2)
cout<<"\n\nThe Entered Alphabets represent
a Palindrome";
else
cout<<"\n\nThe Entered Alphabets do NOT
represent a Palindrome";
break;
}

case 2:
{
clrscr();
cout<<"\n\nEnter Six Characters Alphabet: ";
cin>>c1>>c2>>c3>>c4>>c5>>c6;

if (c6==c1&&c5==c2&&c4==c3)
cout<<"\n\nThe Entered Alphabets represent
a Palindrome";
else
cout<<"\n\nThe Entered Alphabets do NOT
represent a Palindrome";
break;
}

default:
{
cout<<"\n\nInvalid Entry...";
getch();
exit(0);
}
break;
}
break;
}

case 2:
{
clrscr();

cout<<"\n\n1-Five Digit Integer\n\n2-Six Digit Integer";


cout<<"\n\nEnter Option: ";
cin>>op2;

switch (op2)
{

case 1:
{
clrscr();

cout<<"\n\nEnter Five Digit Integer: ";


cin>>no;

c1=no/10000;
no=no%10000;
c2=no/1000;
no=no%1000;
c3=no/100;
no=no%100;
c4=no/10;
c5=no%10;

if (c5==c1&&c4==c2)
cout<<"\n\nThe Entered Digits represent a
Palindrome";
else
cout<<"\n\nThe Entered Digits do NOT represent a
Palindrome";
break;
}

case 2:
{
clrscr();
cout<<"\n\nEnter Six Digit Integer: ";
cin>>no;

c1=no/100000;
no=no%100000;
c2=no/10000;
no=no%10000;
c3=no/1000;
no=no%1000;
c4=no/100;
no=no%100;
c5=no/10;
c6=no%10;

if (c6==c1&&c5==c2&&c4==c3)
cout<<"\n\nThe Entered Digits represent a
Palindrome";
else
cout<<"\n\nThe Entered Digits do NOT
represent a Palindrome";
break;
}
default:
{
cout<<"\n\nInvalid Entry...";
getch();
exit(0);
}
break;
}
break;
}

default:
{
cout<<"\n\nInvalid Entry...";
getch();
exit(0);
}
}

getch();
}

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006