Q. Accept a character as input and check whether the character is a digit
Program
#include<stdio.h>
int main()
{
char character;
printf("Enter a Character\n");
scanf("%c", &character);
if(character >= '0' && character <= '9')
{
printf("%c is a Digit \n", character);
}
else
{
printf("%c is a not Digit \n", character);
}
}
Output:
Enter a Character
5
5 is a Digit
Program
#include<stdio.h>
int main()
{
char character;
printf("Enter a Character\n");
scanf("%c", &character);
if(character >= '0' && character <= '9')
{
printf("%c is a Digit \n", character);
}
else
{
printf("%c is a not Digit \n", character);
}
}
Output:
Enter a Character
5
5 is a Digit
0 Comments