Problem 11

author
By Supreme2023-02-23
Problem Statement :
Write a C program to check whether the entered character is capital, small letter, digit or any special character
Code:

#include <stdio.h>

int main()
{

// 11. Write a C program to check whether the entered character is capital, small letter,
// digit or any special character

printf("\tCharacter Recognizer");
printf("\n==========================================");

char c;

printf("\n Enter Any Character : ");
scanf("%ch", &c);

printf("\n__________________________________________\n");

if (c >= '0' && c <= '9')
{
printf("\n Entered Character Is Digit...");
}

else if (c >= 'a' && c <= 'z')
{
printf("\n Entered Character Is Small Latter...");
}

else if (c >= 'A' && c <= 'Z')
{
printf("\n Entered Character Is Capital Latter...");
}

else
{
printf("\n Entered Character Is Special Character...");
}

// if(c>=48 && c<=57){
// printf("\n Entered Character Is Digit...");
// }
//
// else if(c >= 97 && c <= 122 ){
// printf("\n Entered Character Is Small Latter...");
// }
//
// else if(c >=65 && c <=90){
// printf("\n Entered Character Is Capital Latter...");
// }
//
// else{
// printf("\n Entered Character Is Special Character...");
// }

printf("\n__________________________________________\n\n");

return 0;
}

Description :
  • This code is a C program that checks whether the entered character is a capital letter, small letter, digit, or any special character.
  • The program starts by printing a message to indicate what the program does. Then, it declares a character variable named "c" to store the user's input.
  • Next, the program reads the user's input using the "scanf" function. After that, the program checks if the entered character is a digit, a small letter, a capital letter, or a special character using a series of if-else statements.
  • Finally, the program prints a message indicating the type of character entered by the user. The program then ends by returning 0.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.