Saturday, August 18, 2018

REVERSE STRING

  • Problem Description

    Reverse String using Pointers in C
  • CODING ARENA
  • #include <stdio.h>
    #include<string.h>
    int main()
    {
      char str[100];
      int i,len;
      scanf("%s",str);
      len=strlen(str);
      for(i=len-1;i>=0;i--)
      {
        printf("%c",str[i]);
      }
      
      return 0;
    }
  • Test Case 1

    Input (stdin)
    Cse
    
    
    Expected Output
    esC
  • Test Case 2

    Input (stdin)
    Department
    
    
    Expected Output
    tnemtrapeD

No comments:

Post a Comment