;

C program to Reverse a String without using strrev() and Print Directly


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to reverse a string without using strrev() and print directly.

Here is the code of the program to reverse a string without using strrev() and print directly.

Code - C program to Reverse a String without using strrev() and Print Directly
/* C program to Reverse a String without using strrev() and Print Directly*/
 
#include <stdio.h>
#include <string.h>
 
void main()
{
  	char Str[100];
  	int i, len;
 
  	printf("Enter a String: ");
  	gets(Str);
  	
  	len = strlen(Str);
  	
 	printf("Reverse String is = "); 
  	for (i = len - 1; i >= 0; i--)
  	{
  		printf("%c", Str[i]);
  	}

}
Output

Enter a String: Tutorialsrack
Reverse String is = kcarslairotuT
--------------------------------
Process exited after 4.861 seconds with return value 84
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags