//Program to check whether an entered number is zero,positive,or negative
#include<conio.h>
#include<stdio.h>
void main()
{
int n;
char ch='y';
do
{
fflush(stdin);
printf("\n\nENTER THE NUMBER=");
scanf("%d",&n);
if(n>0)
printf("\n\n%d IS A POSITIVE NUMBER ",n);
if(n<0)
printf("\n\n%d IS A NEGATIVE NUMBER ",n);
if(n==0)
printf("\n\n%d IS A ZERO NUMBER ",n);
printf("\n\nDO YOU WANT TO CONTINUE?:- ");
scanf("%s",&ch);
}while(ch=='y'||ch=='Y');
getch();
}
/********************************************************************
OUTPUT
********************************************************************
3 IS A POSITIVE NUMBER
DO YOU WANT TO CONTINUE?:- y
ENTER THE NUMBER=5
5 IS A POSITIVE NUMBER
DO YOU WANT TO CONTINUE?:- y
ENTER THE NUMBER=4
4 IS A POSITIVE NUMBER
DO YOU WANT TO CONTINUE?:- y
ENTER THE NUMBER=4
4 IS A POSITIVE NUMBER
DO YOU WANT TO CONTINUE?:- y
ENTER THE NUMBER=-3
-3 IS A NEGATIVE NUMBER
DO YOU WANT TO CONTINUE?:- y
ENTER THE NUMBER=0
0 IS A ZERO NUMBER
DO YOU WANT TO CONTINUE?:-
n
*/
No comments:
Post a Comment