24. Program to Check Whether a Number is Positive or Negative

void main()
{
float c;
clrscr();
printf("Enter a number: ");
scanf("%f",&c);
if (c<=0)
{
if (c==0)
printf("You entered zero.");
else
printf("%.2f is negative.",c);
}
else
{
printf("%.2f is positive.",c);
}
getch();
}

Comments

  1. #include
    void main()
    {
    float c;
    clrscr();
    printf("Enter a number: ");
    scanf("%f",&c);
    if (c<=0)
    {
    if (c==0)
    printf("You entered zero.");
    else
    printf("%.2f is negative.",c);
    }
    else
    {
    printf("%.2f is positive.",c);
    }
    getch();
    }

    ReplyDelete

Post a Comment