Thursday, April 26, 2018

C program to check whether a number is positive, negative or zero.

Program code
#include <stdio.h>
#include <conio.h>
void main()
{
  int num;
  clrscr();
  printf("Please input a number.\n");
  scanf("%d", &num);
  if (num= = 0)
  printf("%d is zero.",num);
  else if (num>0)
  printf("%d is positive.",num);
  else
  printf("%d is zero.",num);
  getch();
}

Example of Output
Please input a number.
13
13 is positive.



No comments:

Post a Comment

Please write here, your opinion about this C program