Last Question in C Exam Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int is_alphabet(char letter) | |
{ | |
if (letter >= 'a' && letter <= 'z') return 1; | |
if (letter >= 'A' && letter <= 'Z') return 1; | |
return 0; | |
// we don't need else because we are returning | |
} | |
int main() | |
{ | |
char letter; | |
printf("Enter a character: "); | |
scanf("%c", &letter); | |
if (is_alphabet(letter)) | |
printf("It's an alphabet"); | |
else | |
printf("It's not an alphabet"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment