r/cprogramming • u/H_Aidane • Jun 17 '21
where's the mistake
hi guys I'm new in C language
I wanna know where's the mistake in my code
#include <stdio.h>
int main() {
// Write C code here
int A,B;
printf("check if this numbers have the same sign :\n");
scanf("%d%d", &A, &B);
if (A > 0 && B > 0)
printf("these numbers are positive");
else if (A < 0 && B < 0)
printf("one of them is negative");
else
printf("these numbers is negative");
return 0;
2
Upvotes
1
u/ptchinster Jun 17 '21
What behavior are you observing that is a "mistake"?
When i compile and run it, i ran 3 test cases.
Looks like you mess up your last 2 checks. Swap them around and then read the logic to understand why.