Hello everyone,
I'm new to this forum as well as c programming. I could use some guidance on a program I am trying to write. I need the program to analyze the below character and print out. I need to use if if-else or switch statements and I am lost.
- an alphabetic character (a-z or A-Z)
- a digit (0-9) or
- a special character (anything else)
Code:
#include <stdio.h>
using namespace std;
int main()
{
char character;
int number = 0;
printf ("Please enter a character\n"); /*Asks the user to enter a character*/
scanf("%c",&character);
if (character >= 'a' && character <= 'z') {
printf("You entered a character from a-z");
}
if (character >= 'A' && character <= 'Z') {
printf("You entered a character from A-Z");
}
if (number >= '0' && number <= '9')
printf("You entered a digit 0-9\n");
else {
printf("You entered a special character");
}
fflush(stdin);
getchar();
return 0;
}