Qn: Write a C program to reverse a given string
-By Admin, Last Update On 27th May,2019 11:50 pm
#include<stdio.h>
#include<conio.h>
int main () {
   char mystring[30] = "Thomas Edison";
   int length=strlen(mystring);
   int i;
   char temp;
   for(i=0;i<length/2;i++){
    temp=mystring[i];
    mystring[i]=mystring[(length-1)-i];
    mystring[(length-1)-i]=temp;
   }
   printf("Reversed String is:\n%s",mystring);
   return 0;
  }

Output:

Reversed String is:
nosidE samohT

Pgcomments

Comments