Discussion Forums

New User? Please read instructions!

C program to check whether given number is positive or negative  

  RSS

thiyagarajan
Eminent Member
Joined: 1 month  ago
Posts: 26
27/01/2017 9:48 am  

C program to check whether given number is positive or negative


ReplyQuote
admin
Eminent Member
Joined: 5 years  ago
Posts: 26
10/02/2017 9:57 am  

Below C program will check whether a given number is positive or negative or zero.

 

#include <stdio.h>

int main()

{

    float n;

    printf("Please enter a number\n");

    scanf("%f",&n);

    

    if (n==0)

        printf("\nEntered number is 0. It's neither positive or negative");

    else if (n<0)

        printf("\nEntered number %.2f is negative.",n);

    else

        printf("\nEntered number %.2f is positive.",n);

    return 0;

}

 

Output:

Please enter a number

-15

Entered number -15.00 is negative.


ReplyQuote
  
Working

Please Login or Register

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!