Write a C Program to Check Whether it is Alphabet or Number

July 12, 2022 0 Comments

In this tutorial learn how you can write a c program to enter a character from keyboard and check whether it is alphabet or number. If character is an lowercase alphabet convert it to uppercase and vice versa. The program should use unformatted I/O functions.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.


write c program to check whether it is alphabet or number



Write a Program to Check Whether it is Alphabet or Number

Here is the code to enter a character from keyboard and check whether it is alphabet or number. If character is an lowercase alphabet convert it to uppercase and vice versa. The program should use unformatted I/O functions. in C programming.

#include <stdio.h> //WAP to enter a character from keyboard and check whether it is alphabet or number. If character is an lowercase alphabet convert it to uppercase and vice versa. The program should use unformatted I/O functions.
#include <ctype.h>
int main()
{
char word;
puts("Please enter any character:");
word = getchar();
if (isalpha(word))
{
if (isupper(word) == 1)
putchar(tolower(word));
else
putchar(toupper(word));
}
else
{
putchar(word);
puts(" is number.");
}
return 0;
}

Test Live At Jdoodle



Conclusion

This is how you can enter a character from keyboard and check whether it is alphabet or number. If character is an lowercase alphabet convert it to uppercase and vice versa. The program should use unformatted I/O functions in c programming. Comment below if you like our tutorial.

Leave a comment

Gallery