#include<conio.h>
void strev(char str1[50], char str2[50]);
void main()
{
char str1[50], str2[50];
clrscr();
printf(“\n——————————————————–”);
printf(“\n\n PROGRAM TO REVERSE THE GIVEN STRING “);
printf(“\n\n——————————————————–”);
printf(“\n\n\t ENTER A STRING…: “);
gets(str1);
strev(str1,str2);
printf(“\n\t THE REVERSED STRING IS…: “);
puts(str2);
printf(“\n\n——————————————————-”);
getch();
}
void strev(char str1[50], char str2[50])
{
int i = 0, len = 0, r = 0;
while(str1[len]!=’\0′)
len++;
for(i=len-1; i>=0; i–)
{
str2[r] = str1[i];
r++;
}
str2[r] = ‘\0′;
}
Not Satisfied ? Just search & get the result
Related posts:
- C Program to accepts two strings and compare them. Finally it prints whether both are equal, or first string is greater than the second or the first string is less than the second string
- C program – Morse code to text conversion and vice-versa.
- C Program to accept two strings and concatenate them i.e.The second string is appended to the end of the first string
- C program to read two strings and concatenate them (without using library functions). Output the concatenated string along with the given string
- C program to accept a string and find the sum of all digits present in the string
