SUMMER TRAINING Free Tutorials  Go To Your University  Placement Preparation 
Project Based Best Summer Training Courses in Jaipur
Join our Telegram Channel To take free Online Courses

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

Reverse a String

In this program we are going to reverse a user provided string using C programming.

To learn basics of string in C programming Click Here.

Example :

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[100],revstr[100];
int i,j=0;
clrscr();

//Take input string from user
printf("\nEnter a string:");
gets(str);


//To access each element from string in reverse order
for(i=strlen(str)-1;i>=0;i--)
{
revstr[j]=str[i];
j++;
}
printf("\nReversed:\n");
puts(revstr);

getch();
}

Output :

Output of above program showing reversed string


For More GTU C Programming Lab Experiments Click Here

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...