1. Evaluate the truth value of the following expression. Show your work 10%8e2 1
ID: 3869947 • Letter: 1
Question
1. Evaluate the truth value of the following expression. Show your work 10%8e2 11 !(24/8>3) && 5/21+2.5 2. Two football teams, C and F, play against each other and have their final scores saved in variables scoreC and scorel respectively,. Write the code segment that compares these two score totals and prints a message stating whether C won the game, F won the game, or whether the game was tied Write a valid C statement to check if a user's input value is in the range of 70 and 80, inclusive. Display a message stating if it is range or not 3. 4 Trace the following statements and show the output if the user enters a value of x of: a) 40 b)100 if [x -100) { x -x3 else if (x4- 10) 1 else f n-n+ 3 printf("The value of x is: dn,x) (over)Explanation / Answer
1)
There are 3 main equations, (10%8<2) !(24/8>3) 5/2!=2.5
Lets solve each individually,
10%8 will be 2,
2<2 is false. The first statement is False
24/8 = 3
3 > 3 is false
!false will be true. So the 2nd statement is true
5/2 = 2.5
2.5 != 2.5, but both are equal, so the 3rd statement is false.
In ||(bit wise OR) , &&(bit wise AND) the precedence is AND. So first take 2nd and 3rd truth values with AND.
True AND False will be False only
Now take the result False with 1st stamen with OR operator.
False OR False will be False only.
So, the overall truth value is FALSE.
//2
#include<stdio.h>
int main()
{
int scoreC=12;//C score
int scoreF=15;//F score
//if both scores equal, then game was tied
if(scoreC==scoreF)
printf("The game was tied ");
//if C's score was greater than F's score then
//C won the game
else if(scoreC>scoreF)
printf("C won the game ");
//if game not tied or C not won the game, then
//obviously F won the game
else
printf("F won the game ");
}
//3
#include<stdio.h>
int main()
{
int input;//input value will be stored in input variable
printf("Please enter input value: ");
scnaf("%d",&input);//storing into input variable
//value in the range 70 and 80
if(input>=70 && input<=80)
printf("The input value is in the Range ");
//if not in the range 70 and 80
else
printf("The input value is not in the Range ");
}
4)
X =40 :
40 < 60, so x will be 40*2, that is 80
80 not >= 100, it wont go to inside if
80/4 will be 20, which is not equal to 10, so it wont go to inside the else if
The control not went to if and else if, it will be go else, here the new variable n present, which is not effect the x variable.
X value will be printed as 80
X = 100 :
100 < 60, so it wont go to first if
100>=100, so it will go to 2nd if and the value of x will 100/3 which 33.333, we are thinking that n is integer, so it will take x as 33
Control went to 2nd if statement, so it wont go to else condition.
The x value will be printed as 33
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.