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

Write a program to classify a character as upper case letter, lower case letter,

ID: 3700539 • Letter: W

Question

Write a program to classify a character as upper case letter, lower case letter, or not-an-alphabet Three cases of the program runs are shown as follows Please enter a character: $ $ is not a alphabet Please enter a character: e e is a lower case letter Please enter a character: F F is an upper case letter Please use turbo debugger to run and debug the program Submit copies of 1. Source codes 2. Screen shot of turbo debugger process showing codes along with the variables defined in the DS segment 3. Three cases of the program runs

Explanation / Answer

Here is the program which identifies and uppercase or lowercase letter or not an alphabet:

#include <stdio.h>

int main()
{
char character;

/* Take the input character from the user */
printf("Please enter the character: ");
scanf("%c", &character);


if(character >= 'A' && character <= 'Z')
{
printf("'%c' is an uppercase letter.", character);
}
else if(character >= 'a' && character <= 'z')
{
printf("'%c' is a lowercase letter.", character);
}
else
{
printf("'%c' is not an alphabet.", character);
}

return 0;
}

We can also use the inbuild functions to check above things. We can use isupper() or islower() functions to find out the same. Here is the program using these functions:

#include <stdio.h>

int main()
{
char character; //Defining a single variable needed to get the input from user

/* Take the input character from the user */
printf("Please enter the character: ");
scanf("%c", &character);


if(isupper(character))
{
printf("'%c' is an uppercase letter.", character);
}
else if(islower(character))
{
printf("'%c' is a lowercase letter.", character);
}
else
{
printf("'%c' is not an alphabet.", character);
}

return 0;
}

So if we run bove program:

Output:

Please enter the character:

A is an upper case letter

a is a lower case letter

3 is not an alphabet

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote