Saturday, March 31, 2018

Recursive reverse (Id-1250)

Just for Practice 1 Additional [3-Jan-2018 to 10-Apr-2018]

Program ID- 1250

Given a string, write a recursive routine to reverse it. For example, given the string ‘and, the reversal of the string is ‘dna’.
Input Format

A string

Output Format

Reverse of the string

Code: C

#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char str[100];
    scanf("%s",&str);
    for(i=strlen(str)-1;i>=0;i--)
    {
        printf("%c",str[i]);
    }
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

No comments:

Post a Comment