Create a program that prompts the user to enter a single character. Display its ASCII value, convert it to uppercase, and then display the modified character. Use appropriate data types.
#include <stdio.h>
int main() {
// Declare variables to store user input and results
char inputChar;
int asciiValue;
char upperCaseChar;// Input: Get a single character from the user
printf(“Enter a single character: “);
scanf(” %c”, &inputChar); // Note the space before %c to consume any previous newline character// Process: Calculate ASCII value and convert to uppercase
asciiValue = (int)inputChar;// Check if the input is an uppercase letter before converting
if (inputChar >= ‘a’ && inputChar <= ‘z’) {
upperCaseChar = inputChar – (‘a’ – ‘A’);
} else {
upperCaseChar = inputChar; // Input is already uppercase or not a letter
}// Output: Display results
printf(“ASCII Value: %dn”, asciiValue);
printf(“Uppercase Conversion: %cn”, upperCaseChar);return 0; // Exit the program successfully
}