Skip to content

Instantly share code, notes, and snippets.

@s3f
Created December 29, 2016 22:46
Show Gist options
  • Save s3f/94411b13019b5b8ed1673276507f1210 to your computer and use it in GitHub Desktop.
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 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