C program to check whether a given integer number is positive or negative

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/* Write a C program to check whether a given integer number is positive or negative */

#include <stdio.h>
#include <conio.h>

void main()
{
int number;
clrscr();

printf(“Enter a number\n”);
scanf (“%d”, &number);

if (number > 0)
printf (“%d, is a positive number\n”, number);
else
printf (“%d, is a negative number\n”, number);

}
/*—————————–
Output
Enter a number
-5
-5, is a negative number

RUN2
Enter a number
89
89, is a positive number
——————————*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program to check whether a given integer is odd or even
  2. Sample – check if a number is prime
  3. Sample – Program to enter an integer and print its total value based on the formula ‘x – 1/3!x3 + 1/5!x5 – 1/7!x7 + 1/9!x9′.
  4. Sample – Program to convert 2-digit octal number into binary number and print it.
  5. Sample – Program to enter an integer and output the cube of that integer.

Leave a Comment

Previous post:

Next post: