5)Write a C program to reverse a string using static implementation of static.


#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],out[30];
int i,j;
clrscr();
printf(“\n\nENTER UR STRING\t”);
gets(in);
for(i=0;in[i]!=”;i++)
{
push(in[i]);
}
j=0;
while(top!=-1)
{
out[j++]=pop();
}
out[j]=”;
printf(“%s”,in);
printf(“\n\n%s”,out);
if(strcmp(in,out)==0)
{
printf(“\n\nSTRING IS PALLINDROME”);
}
else
{
printf(“\n\nSTRING IS NOT PALLINDROME”);
}
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