|
CS256 - Principles of Structured Design
Fall 2021
|
Displaying ./code/cs256su21code/jun01/count6.c
/*
similar to count.c but now we are starting at 10 and counting down to 1
*/
#include <stdio.h>
int main()
{
int num = 10;
while(num >= 1){
printf("%d\n", num);
num--;
/*
similar to how num++ increases a value by 1, num-- will decrease a value by 1
this is known as the decrement operator.
like the other examples show, if you want to decrement by some value other than 1
you need a statement like "num = num - dec" where dec is the number we are decreasing
num by.
*/
}
return 0;
}
|