How to use >= in comparing with 0? Is this code is right? Please answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to use >= in comparing with 0? Is this code is right? Please answer

#include<stdio.h> int main() { int a; scanf("%d ", &a); if( a >= 0) printf("Ok"); else printf("Not ok"); return 0; }

18th Aug 2022, 3:05 AM
Umme Hafsa
Umme Hafsa - avatar
1 Answer
+ 3
what do you mean by "this code is right?"? Your code prints "Ok" for integers greater or equal to 0 and "Not ok" for integers less than 0 (negatives). if this is what you want then it's right.
18th Aug 2022, 4:40 AM
Tina
Tina - avatar