Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Write a program that takes an uppercase alphabet letter as input and converts it to lowercase, and vice versa, using a switch statement.

#include <stdio.h>

int main() {
char inputChar, convertedChar;

// Taking input for the alphabet letter
printf(“Enter an uppercase or lowercase alphabet letter: “);
scanf(” %c”, &inputChar);

// Using a switch statement to convert the letter
switch (inputChar) {
case ‘A’ … ‘Z’:
convertedChar = inputChar + (‘a’ – ‘A’);
printf(“Converted to lowercase: %cn”, convertedChar);
break;
case ‘a’ … ‘z’:
convertedChar = inputChar – (‘a’ – ‘A’);
printf(“Converted to uppercase: %cn”, convertedChar);
break;
default:
printf(“Invalid input. Please enter an uppercase or lowercase alphabet letter.n”);
}

return 0;
}