How to recognize positive or negative numbers with c language? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to recognize positive or negative numbers with c language?

Please write a code that determines that the user's number is positive or negative or zero, please write with C

4th Dec 2018, 10:19 AM
Alireza
Alireza - avatar
1 Answer
+ 10
● greater than 0 is +ve & less than 0 is negative[ 0 is not +ve, nor -ve] ● scanf() method to take user input . //here is the rough code : #include <stdio.h> int main() { int a; scanf("%d", &a); if (a>0) printf("postive"); else if (a <0) printf("negative"); return 0; }
4th Dec 2018, 10:34 AM
Gaurav Agrawal
Gaurav Agrawal - avatar