Program to reverse
the given string
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20], rev[20];
int i, j, l;
clrscr();
printf("Enter a string : ");
scanf("%s", str);
for(l = 0 ; str[l] != '\0' ; l++);
for(i = l - 1, j = 0 ; i >= 0 ; i--, j++)
rev[j] = str[i];
rev[j] = '\0';
printf("\nThe given string is : %s\n\n", str);
printf("The reversed string is : %s", rev);
getch();
}
Output:
Enter a string : bhuvan
The given string is : bhuvan
The reversed string is : navuhb
-
UpdatedDec 31, 2019
-
Views5,232
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order