Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with my current code. Create a program where a user inputs a lowe

ID: 3662217 • Letter: P

Question

Please help me with my current code.

Create a program where a user inputs a lowercase letter and returns it in an uppercase form in the next line. Example: Enter a letter: a A.

check that the input char is a letter. If it isn’t, print “ That's

not a letter!Try again next time.” followed by a new line and exit the

program.

#include <stdio.h> /*printf, scanf definitions */

#include <ctype.h> /*performs character classification */

int main (void){

char lower, upper;

lower= getchar();

printf("Enter a letter: ");

scanf("%c", &lower);

upper= toupper (lower);

putchar (upper) );

}

Explanation / Answer

Solution:

#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
char lower, upper;

printf(" Enter a letter: ");
scanf("%c", &lower);

if (isalpha(lower)){
upper= toupper (lower);
printf(" Upper case = %c " ,upper);
}else{
    printf(" That's not a letter!Try again next time. ");
}
   return 0;
}

Output

Enter a letter: a

Upper case = A

__________Another sample output_________

Enter a letter: 22

That's not a letter!Try again next time.