Created
December 29, 2016 22:46
-
-
Save s3f/94411b13019b5b8ed1673276507f1210 to your computer and use it in GitHub Desktop.
Chapter 10- Assignments and Expressions created by s3f - https://repl.it/EdrJ/2
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
// This practice program increases a counter from 1 to 5 and then decreases it | |
#include <stdio.h> | |
main() | |
{ | |
int ctr = 0; | |
ctr += 1; | |
printf("Counter is at %d.\n", ctr); | |
ctr += 1; ; | |
printf("Counter is at %d.\n", ctr); | |
ctr += 1; ; | |
printf("Counter is at %d.\n", ctr); | |
ctr += 1; ; | |
printf("Counter is at %d.\n", ctr); | |
ctr += 1; ; | |
printf("Counter is at %d.\n", ctr); | |
ctr -= 1; | |
printf("Counter is at %d.\n", ctr); | |
ctr -= 1; | |
printf("Counter is at %d.\n", ctr); | |
ctr -= 1; ; | |
printf("Counter is at %d.\n", ctr); | |
ctr -= 1; ; | |
printf("Counter is at %d.\n", ctr); | |
return 0; | |
//ctr += 1 is the same as ctr = ctr + 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment