Last active
February 7, 2020 16:48
-
-
Save Cython-dot/e0fe51c55ae43ded06f01654bf5d9f34 to your computer and use it in GitHub Desktop.
C | main
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) | |
{ | |
int age = 15; | |
(age == 15) ? printf("You're 15 years old. \n") : printf("You're not 15 years old.\n"); | |
return 0; | |
} | |
/* | |
print in console: You're 15 years old. | |
Program ended with exit code: 0 | |
*/ |
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) | |
{ | |
int age = 15; | |
int he_is_fifteen = -1; | |
he_is_fifteen = (age == 15) ? 1 : 0; | |
printf("He is fifteen = %d\n" , he_is_fifteen); | |
return 0; | |
} | |
/* | |
print in console: He is fifteen = 1 | |
Program ended with exit code: 0 | |
*/ |
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) | |
{ | |
int i = 0; | |
while(i < 20) | |
{ | |
printf("All is good in the hood ! \n"); | |
i++; | |
//++ incrementation guarantees that the loop continues the operation not undefinetly but untill it fulfill the condition. | |
} | |
return 0; | |
} | |
/* | |
print in console: | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
All is good in the hood ! | |
--------- | |
* 20 times because we started from 0. | |
--------- | |
Program ended with exit code: 0 | |
*/ |
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) | |
{ | |
int i = 6; | |
do{ | |
// This condition guarantees we get into the loop at least once before we find out if we meet the condition or not. | |
printf("Where u at? \n"); | |
i++; | |
} | |
while(i < 5); | |
return 0; | |
} | |
/* | |
print in console: Where u at? | |
Program ended with exit code: 0 | |
*/ |
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) | |
{ | |
int age = 111; | |
switch(age) | |
{ | |
case 0: | |
printf("You are 0 year old.\n"); | |
break; | |
case 15: | |
printf("You are 15 years old.\n"); | |
default: | |
printf("You are neither 0 nor 15 years old.\n"); | |
} | |
return 0; | |
} | |
/* | |
print in console: You are neither 0 nor 15 years old. | |
Program ended with exit code: 0 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment