c_programming

C programming: Check whether a number is positive or negative


Here we are sharing C programs on various topics such as strings, series, arrays, loops, geometrical figures, mathematical calculation, sorting & searching algorithms and many more. 

Code Description

Enter an integer you want to check as input. This integer is then stored in the variable ‘number’. Now the program execution is done by checking whether this given integer is greater or lesser than zero.If it is greater than or equal to zero, then it is a positive number” otherwise it is a negative number.

// Created by Kaustav Ghosh Dastidar.
#include <stdio.h>o
int 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);
return 0;
}

Output1

Output2

We are aiming to provide you a good packaged solution under one umbrella. For all the possible C programming questions which might you have faced in interviews or any other assignments or projects. If you are not able to find the desired solution, please drop us comments so that we can get back to you to with some more and more beautiful programs. You can also check out our ebook below by clicking the image anywhere which will help you for further practice and quick learning.

 

 

Note: Currently discount is also going on the ebooks

 

c programming examples with explanation

Add a Comment

Your email address will not be published. Required fields are marked *