Reversing string in C

#include <stdio.h>
#include <string.h>

int main(void) {
char a[30] = "Sumant is learning new things";

  printf("%s",a);

  printf("\n");

char temp;
 for(int  i=0, j=strlen(a)-1; i <j;i++,j--)
   {
     temp =a[i];
     a[i] = a[j];
     a[j] = temp;
   }
  printf("%s",a);
  return 0;
}

About Sumant Sumant

I love Math and I am always looking forward to collaborate with fellow learners. If you need help learning math then please do contact me.
This entry was posted in Algorithm, Computer Program, Programming and tagged . Bookmark the permalink.

Leave a comment