Skip to content

Instantly share code, notes, and snippets.

@max-programming
Created November 8, 2022 05:43
Show Gist options
  • Save max-programming/8ef1811d8111ddde05aeeccb096741fe to your computer and use it in GitHub Desktop.
Save max-programming/8ef1811d8111ddde05aeeccb096741fe to your computer and use it in GitHub Desktop.
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