logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/h3sol/oddEven.c

/*

oddEven.c - find whether the given number is odd or even

Hint: You'll want to use a modulus statement here. Numbers that are even are 
      divisible by 2, so if you take any even number mod 2, you'll get 0.
		

*/

#include <stdio.h>

int main(){

	int num; //variable declaration

	printf("Please enter a number> "); //ask the user for a number
	scanf("%d", &num);//use scanf to get that number

	//then use an if statement to determine what we tell the user
	if(num % 2 == 0)//if the number is even, tell the user it's even
		printf("%d is even\n", num);
	else //if not, tell the user that it's odd
		printf("%d is odd\n", num);

	return 0;

}