Thursday 10 November 2016

C Program to reverse a String

  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. void main(){  
  4.   char str[20];  
  5.   clrscr();  
  6.   printf("Enter string: ");  
  7.   gets(str);//reads string from console  
  8.   printf("String is: %s",str);  
  9.   printf("\nReverse String is: %s",strrev(str));  
  10.   getch();  
  11. }    
Output:
Enter string: welcome
String is: welcome
Reverse String emoclew

No comments:

Post a Comment