adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to reverse the given string.

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:-




Post a Comment

0 Comments