logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun01/count2.c

/*

similar to count.c, but demonstrating an if-else statement

here, if num = 5, we print the word "five" instead of the 
number itself.

*/


#include <stdio.h>

int main()
{
	int num = 1;


	while(num <= 10){

		if(num == 5){ 
			//if what's inside the if statement is true, do this
			printf("five\n");
		} else {
			//if what's inside the if statement is false, do this
			printf("%d\n", num);
		}
		
		num++; // updates num
	}


	return 0;
}