WAP to reverse a string ?
#include<stdio.h>
#include<string.h>
int main()
{
char string[50], temp;
int i, k= 0;
printf("\nEnter the string :");
gets(string);
i = 0;
k= strlen(string) - 1;
while (i < k)
{
temp = string[i];
string[i] = string[k];
string[k] = temp;
i++;
k--;
}
printf("\nReverse string is :%s", string);
return (0);
}
Out put
Enter the string : Asmit
Reverse string is : timsA
No comments:
Post a Comment