Last active
January 19, 2021 22:49
-
-
Save sojohnnysaid/bf48cb2a391a176c0bdfd589503677a3 to your computer and use it in GitHub Desktop.
This file contains 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){ | |
// Example 2: conditional structures. | |
int answer = 42; | |
if (answer == 42) //Only runs the line below if true | |
printf("You have found the answer! It is %d\n\n", answer); | |
else // Only runs the line below if false | |
printf("WRONG!!!!"); | |
//---------------------------------- | |
// Example 2: conditional structures | |
// Notice the next conditional has curly brackets | |
// between the execution blocks. | |
// This is because multiline blocks of code need to be wrapped | |
// while a single line statment does not require the curly brackets | |
if (0){ | |
printf("one\n"); | |
printf("two\n"); | |
} | |
else if(1){ | |
printf("three\n"); | |
printf("four\n"); | |
} | |
else{ | |
printf("no more numbers!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment