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

Popular posts from this blog

Write a program to check if a number is prime or not.

write a program (keep taking numbers as input from user until user enters an Odd number)

write a program to print all the odd numbers from 1 to 100.