Completely Solved C, C++ Programs Assignment.




C Prongram to accept a string and print each word in reverse

Filed Under:

Problem 90. C Prongram to accept a string and print each word in reverse
#include<conio.h>
#include<stdio.h>
main( )
{
char name[80];
int i,j,start=0,end,len;
clrscr( );
printf(“enter a string”);
scanf(“%s”,name);
for(i=0;i<80 &&((name[i]=getchar( ) )!=’n’);i++);
len=i;
for(i=0;i<len;i++)
if(name[i]==’ ‘|| name[i]==’n’)
{
end=i;
while((end--)>=start)
{
printf(“%c”,name[end]);
}
start=i+1;
}
getch( );
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments