Saturday, August 18, 2018

CHANGE CASE

  • Problem Description

    program to convert upper case to lower case and lower case to upper case
  • CODING ARENA
  • #include <stdio.h>
    #include<string.h>
    int main()
      char str[20];
      int i;
      scanf("%s",str);
      for(i=0;i<strlen(str);i++)
      {
        if(str[i]>=65&&str[i]<=90)
        {
          str[i]=str[i]+32;
        }
        else if(str[i]>=97&&str[i]<=122)
        {
          str[i]=str[i]-32;
        }
      }
      printf("%s",str);
      return 0;
    }
      
  • Test Case 1

    Input (stdin)
    hai
    
    
    Expected Output
    HAI
  • Test Case 2

    Input (stdin)
    HAI
    
    
    Expected Output
    hai

No comments:

Post a Comment