Basic Conditional Checking for IF statements in C

Posted by ZaZu on Stack Overflow See other posts from Stack Overflow or by ZaZu
Published on 2010-06-02T23:03:55Z Indexed on 2010/06/02 23:04 UTC
Read the original article Hit count: 249

Filed under:
|
|

Hi there,

Can someone please explain what really goes on in this code ? If I put the AND statement, the message wont show if values are less than 0 or greater than 10 ... I think I must use 1 0 logic to work this out right ? I just need someone to briefly explain it please.

#include<stdio.h>
main(){

  puts("enter number");
  scanf("%d",num);
  if(num<0 || num >10)
     puts("yay");
}

How is that IF statement different when AND is put :

#include<stdio.h>
main(){

  puts("enter number");
  scanf("%d",num);
  if(num<0 && num >10)
     puts("yay");
}

Thanks !!

© Stack Overflow or respective owner

Related posts about c

    Related posts about conditional