Write a program in C to reverse the given string.
#include<stdio.h> #include<conio.h> #include<string.h> void main() { int i,l=0; char str[20],ch; clrscr(); printf("Enter a string:-"); gets(str); for(l=0;str[l];l++); for(i=0;i<l/2;i++) { ch=str[i]; str[i]=str[l-1-i]; str[l-1-i]=ch; } printf("Reverse of string=%s",str); getch(); }Output:-
0 Comments