Blogger templates

Pages

Saturday, 19 May 2012

Write a C Program to Check a Number Positive or Negative by using if Statement

Positive and Negative Number

Function of clrscr() :
  • clrscr() Function is used to clear the Previous Output.
  • clrscr() Stands For Clear Screen.
  • clrscr() Function is included in the <conio.h> Header File.
  • clrscr() functions Terminates with the semicolon ( ; ).  
Statement of C Program: Enter a Number From Keyboard and Check It is Positive or Negative.

#include<stdio.h>
#include<conio.h>
void main()

{
int number;
clrscr();
printf(" Enter the value of Number\n");
scanf("%d" ,&number);

if (number > 0)
{
printf(" Number is Positive");
}
else
{
printf(" Number is Negative");
}
getch();
}
Output2:
Enter the value of Number
5
Number is Positive

Output2:
Enter the value of Number
-8
Number is Negative


0 comments:

Post a Comment