/*write a c program which accept the string and reverse each word
of 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();
}
/*
enter the string:-santosh
the length of string is :-7
the reverse string is:-hsotnas
*/
No comments:
Post a Comment