Problem 40

author
By Supreme2023-03-15
Problem Statement :
Write a program to reverse string.
Code:

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

int main(){

//40. Write a program to reverse string.

printf("\tReverse String");
printf("\n=====================================\n\n");

char str[20];

printf("Enter Your String : ");
gets(str);
printf("\nYour String is : ");
puts(str);

printf("\n-------------------------------------\n");
printf("\nYour Reversed String Is : %s",strrev(str));
printf("\n\n-------------------------------------\n");
return 0;
}

Description :
  • This program reverses the input string using the strrev function from the string.h library.
  • The user is prompted to enter a string.
  • The input string is stored in the str array using the gets function.
  • The strrev function is called on the str array to reverse the string.
  • The reversed string is printed to the console using the printf function.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.