Print 1(true) or 0 (false) for following statements :
a. if it's Sunday and it's snowing → 1(true)
let's solve it
#include<stdio.h>
#include<math.h>
int main()
{
int sunday = 1;
int snowing = 1;
printf("%d", sunday && snowing);
// both the conditions are 1(true) therefore output will be 1(true).
return 0;
}
Output :
1
b. if it's Monday or it's raining → 1(true)
let's solve it
#include<stdio.h>
#include<math.h>
int main()
{
int monday = 1;
int raining = 0;
printf("%d", monday || raining);
//since one condition is 1(true), the Output will be 1(true).
return 0;
}
Output :
1
c. if a number is 2 digit → 1(true)
let's solve it
#include<stdio.h>
#include<math.h>
int main()
{
int x;
printf("enter a number");
scanf("%d", &x);
printf("%d", x>9 && x<100);
// if the number is 2 digit output will be 1(true).
//if the number is not 2 digit output will be 0(false).
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in the comment box.