;

C Program to Reverse a String without using strrev() and using strlen() functions


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 using strlen() functions.

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

Code - C Program to Reverse a String without using strrev() and using strlen() functions
/* C Program to Reverse String without using strrev() and using strlen()*/
		
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
	char str[100], temp;
	int i=0, j;
	printf("Enter The String: ");
	gets(str);
	i=0;
	j=strlen(str)-1;
	while(i<j)
	{
		temp=str[i];
		str[i]=str[j];
		str[j]=temp;
		i++;
		j--;
	}
	printf("Reverse of the String = %s",str);
}
Output

Enter The String: tutorialsrack
Reverse of the String = kcarslairotut
--------------------------------
Process exited after 5.319 seconds with return value 37
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags