Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Last Question in C Exam Code
#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