52)Write a C program to read a string and check weather string is palindrome or not(Using static implementation of stack).


#include<stdio.h>
#include<conio.h>
#include<string.h>
char stk[50];
int top=-1;
void push(char c)
{
top++;
stk[top]=c;
}
char pop()
{
char c;
c=stk[top];
top–;
return c;
}
void main()
{
char in[30],b[30];
int i;
clrscr();
printf(“\n\nENTER UR STRING\t”);
gets(in);
for(i=0;in[i]!=”;i++)
{
push(in[i]);
}
i=0;
while(top!=-1)
{
b[i]=pop();
i++;
}
b[i]=”;
if(strcmp(in,b)==0)
{
printf(“\nSTRING is PALLINDROME”);
}
else
{
printf(“\nSTRING IS NOT PALLNDROME”);
}
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s