A simple program demonstrating the use of scanf
and if statements
#include <stdio.h>
int main(void) {
int a, b;
printf("Enter a: ");
scanf("%d", &a);
printf("Enter b: ");
scanf("%d", &b);
if (a > b) {
printf("a is greater than b\n");
} else if (a < b) {
printf("a is less than b\n");
} else {
printf("a is equal to b\n");
}
return 0;
}
A simple program demonstrating the use of scanf
and if statements
#include <stdio.h>
int main(void) {
int a, b;
printf("Enter a: ");
scanf("%d", &a);
printf("Enter b: ");
scanf("%d", &b);
if (a > b) {
printf("%d is greater than %d\n", a, b);
} else if (a < b) {
printf("%d is less than %d\n", a, b);
} else {
printf("%d is equal to %d\n", a, b);
}
return 0;
}
A simple program demonstrating the use of scanf
and chained if statements
Notionally this program is to assist an
inept male straight engineer named George in his interaction with the opposite sex
#include <stdio.h>
int main(void) {
int herAge;
printf("Hi George\n");
printf("Enter her age: ");
scanf("%d", &herAge);
printf("George say this: \"");
if (herAge < 17) {
printf("Do you have an older sister?");
} else if (herAge < 42) {
printf("Would you like to go to a movie Saturday?");
} else if (herAge < 65) {
printf("Do you have a daughter?");
} else {
printf("Do you have a grand-daughter?");
}
printf("\"\n");
return 0;
}
A simple program demonstrating the use of scanf and if statements