Sunday, 15 December 2013

C Program to Check if a given Integer is Positive or Negative

#include < stdio.h>
 
void main()
{
    int number;
 
    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
 -10 
 -10  is a negative number
 
   
Enter a number
 45 
 45  is a positive number

For More Details Please Visit Ictjobs.info

No comments: