01 - WAP to Print Upper Case to Lower Case and vice versa.
This is a Program to print a given letter's from Upper case to lower or Lower case to upper.
#include#include #include int main() { char str[100]; int idx, option, yes; while (1) { printf("Select and option:\n1. Lower Case to Upper Case\n2. Upper Case to Lower Case\n"); printf("Your Option : "); scanf("%d", &option); switch (option) { case 1: printf("Enter a String in Lower Case : "); scanf("%s", str); for (idx=0; idx<=strlen(str); idx++) { if (str[idx]>=97 && str[idx]<=122) { str[idx]=str[idx]-32; } } printf("The String in Upper case is : %s\n", str); break; case 2: printf("Enter a String in Upper Case : "); scanf("%s", str); for (idx=0; idx<=strlen(str); idx++) { if (str[idx]>=65 && str[idx]<=97) { str[idx]=str[idx]+32; } } printf("The String in Lower case is : %s\n", str); break; default: printf("Invalid Entry!\n"); } //this is to run the program printf ("\nTo continue press ['Y'/'n'] : "); getchar(); yes = getchar (); if (!( yes == 'y' || yes == 'Y')) break; } return 0; }
Program Output:
Post a Comment