Problem Description
Write a C program to find reverse of a string without library function.#include <stdio.h>
#include <string.h>
int main()
{
char str[100],revStr[100];
int i,j;
scanf("%[^\n]s",str);
j=0;
for(i=(strlen(str)-1); i>=0; i--)
revStr[j++]=str[i];
revStr[j]='\0';
printf("\n%s",str);
printf("\n%s",revStr);
return 0;
}
Test Case 1
Input (stdin)SRMUniversity
Expected OutputSRMUniversity ytisrevinUMRS
Test Case 2
Input (stdin)ULCSRM
Expected OutputULCSRM MRSCLU
No comments:
Post a Comment