Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Relational Operators 1. check if a length is greater than 2 feet and less than 3

ID: 3673903 • Letter: R

Question

Relational Operators

1. check if a length is greater than 2 feet and less than 3 feet

2. taxRate is over 25% and income is less than $20000

3. temperature is less than or equal to 75 or humidity is less than 70%

4. age is over 21 and age is less than 60

5. age is 21 or 22

6. For what value(s) of x would this condition be true?

        (x < 1) && (x > 10)

7. For what value(s) of y would this condition be true?

        (y >= 1) && (y <= 10)

Write appropriate if statements for each of the following conditions:

8. If the slope is less than .5, set a variable named flag to zero, else set flag to one.

9. Write a program to input an integer number. The program should then output the number and a message saying whether the number is positive, negative, or zero.

10. Write a program to input three numbers and print out the largest number.

11. Write the statements to input a water temperature (in Fahrenheit) and print out the state of the water – freezing, boiling, liquid

Explanation / Answer

1. (length>2) && (length<3)
2.   (taxRate>25) && (income<20000)
3.   (temperature<=75) && (humidity<70)
4.   (age>21) && (age<60)
5.   (age==21) || (age==22)
6.   for any value of X, condition can not be true
7.   y=1,2,3,4,5,6,7,8,9,10

8.   if(slope<0.5){
       flag=0;
   }
   else{
       flag =1;
   }
  
9.  
#include <stdio.h>
int main()
{
   int num;
   printf("Enter a number: ");
   scanf("%d",&num);
  
   if(num > 0 ){
       printf("%d is positive ",num);
       }
   else if(num <0){
       printf("%d is negative ",num);
       }
   else{
       printf("%d is zero ",num);
       }
return 0;
}

10.
#include <stdio.h>
int main()
{
   int num1,num2,num3;
   printf("Enter three number: ");
   scanf("%d",&num1);
   scanf("%d",&num2);
   scanf("%d",&num3);
  
   if(num1>num2){
       if(num1>num3)
           printf("%d ",num1);
       else if(num3>num2)
           printf("%d ",num3);
       }
   else{
       if(num2>num3)
           printf("%d ",num2);
       else
           printf("%d ",num3);
       }
return 0;
}

11.
#include <stdio.h>
int main()
{
   float tem;
   printf("Enter Fahrenheit temperature: ");
   scanf("%f",&tem);
  
   if(tem <=32)
       printf("Freezing ");
   else if(tem >= 212)
       printf("Boiling ");
   else
       printf("Liquid ");
  
return 0;
}