Completely Solved C, C++ Programs Assignment.




C Program to accept a string and print the reverse of the given string by using for loop

Filed Under:

Problem 40. C Program to accept a string and print the reverse of the given string by using for loop.
#include<stdio.h>
#include<conio.h>
main( )
{
int i,j;
char name[80];
clrscr( );
printf(“ enter a string”);
gets(name);
for(i=0;i<80 && ((name [i]=getchar())!=’n’);i++);
if(name[i]= =’n’)
name[i]=’�’;
for(j=i;j>=0;j--)
putchar(name[j]);
printf(“is the reverse of given string”);
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