Home Uncategorized To print individual characters of string in reverse order

To print individual characters of string in reverse order

SHARE


Write a program in C to print individual characters of string in reverse order.

Solution:

#include <stdio.h>

#include<string.h>

int main()

{

   char str[100];

   int i;

   printf(“Enter a string:\n”);

   fgets(str, sizeof str, stdin);

   printf(“Reverse order of given string is:\n”);

   i=strlen(str);

   for(i=i-1;i>=0;i–)

      printf(“%c”,str[i]);

   printf(“/n”);

}

Output:

Enter a string:

Hi this is Ekviz.com

Reverse order of given string is:

moc.zivkE si siht iH

Back to Programs list.