/*write a c program to reverse a string using static implementation
of stack*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,len,top;
char str[50],s[50];
clrscr();
printf("\nenter the string:-");
gets(str);
len=strlen(str);
printf("\nthe length of string is :-%d",len);
for(top=0;top<len;top++)
{
s[top]=str[top];
}
top--;
printf("\nthe reverse string is:-");
for(i=top;i>=0;i--)
{
printf("%c",s[i]);
}
getch();
}
/*---------------OUTPUT---------------
enter the string:-peersaab nadaf
the length of string is :-14
the reverse string is:-fadan baasreep */
No comments:
Post a Comment