C program that determines if a number is equal to zero
Posted by Samath
Last Updated: November 07, 2014

Write a C program that reads a single integer number from the keyboard via the scanf function, determines if the number is equal to zero or not, and then either prints out: "The number is equal to zero." or "The number is not equal to zero.

Here is the solution for the above question:

#include <stdio.h>
int main(int argc, char *argv[])
{
	int num;
	
	printf("Please enter a number: ");
	scanf("%d",&num);
	
	if(num == 0)
	{
		printf("The number is equal to zero.\n");
	}
	else
	{
		printf("The number is not equal to zero.\n");
	}
	
	return 0;
}