-
-
Save SemanticallyNull/1342888 to your computer and use it in GitHub Desktop.
Finally began messing around with C... much is coming back to me now, and realising how little I know.
This file contains hidden or 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 main(void) { // Thanks to @barrettcolin for showing me the way. | |
int age; | |
printf("What is your age? "); | |
scanf("%d", &age); // Accept a numeric input and push it to age (by getting the lvalue of age) | |
if(age < 5) { | |
printf("Wow, you're very young!\n"); | |
} else if(age < 12) { | |
printf("Oh, older now!\n"); | |
} else if(age < 18) { | |
printf("A teenager? Party everyday!\n"); | |
} else { | |
printf("Sorry, you're an adult now. Parties with beer (and whiskey)!\n"); | |
} | |
return 0; // Oops, forgot this originally. Though as it turns out there was no need to do this at all in C99 | |
} // Also forgot the newline at the end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment