APS105 L07 - Decision-Making

#APS105 Slides Lecture Link to web notes
Works because characters are encoded in ASCII, so we can perform math operations on them.
e.g. '0' + 2 = '2'
To convert a lowercase character to uppercase, we can add 32.
e.g. 'a' + 32 = 'A'

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	printf("Enter a character: ");
	char c = "\0";
	scanf("%c", &c);
	bool isUpperCase = (c >= 'A' && c <= 'Z');
	bool isLowerCase = (c >= 'a' && c <= 'z');
	if (isUpperCase || isLowerCase) {
		printf("You entered a letter\n");
	} else {
		printf("You did not enter a letter\n");
	}
	return 0;
}

Rewriting Logic Statements using De Morgan's Laws

!(A || B) == !A && !B
!(A && B) == !A || !B

Always ensure you use brackets with logic statements if needed

Just to make sure compiler does what you mean.
e.g. !(A || B) != !A || B