Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Consider the following selection statement where X is an integer test score between 0 and 100. input X if (0 <= X and X < 49) o...Asked by steve
Consider the following selection statement where X is an integer test score between 0 and 100.
input X
if (0<=X and X<49)
Output "you fail"
Else if (50<=X and X <70)
Output "your grade is" X
Output " you did OK"
Else if (70<=X and X<85)
Output "your grade is"X
Output "you did well"
Else if (85<=X and X<100)
Output "your grade is X
Output "You did great"
Endif
Output "how did you do?"
What will be printed if the input is 0?
input X
if (0<=X and X<49)
Output "you fail"
Else if (50<=X and X <70)
Output "your grade is" X
Output " you did OK"
Else if (70<=X and X<85)
Output "your grade is"X
Output "you did well"
Else if (85<=X and X<100)
Output "your grade is X
Output "You did great"
Endif
Output "how did you do?"
What will be printed if the input is 0?
Answers
Answered by
MathMate
"What will be printed if the input is 0?"
As a programmer, you would following each statement of the if-then-else statement and see where the conditions will be satisfied. Follow what it does (prints) after that.
If you start from the top, you won't have very far to go before you find the answer if someone gets a zero (i.e. X=0).
As a programmer, you would following each statement of the if-then-else statement and see where the conditions will be satisfied. Follow what it does (prints) after that.
If you start from the top, you won't have very far to go before you find the answer if someone gets a zero (i.e. X=0).
Answered by
steve
I am still unaware of the answer.
Answered by
MathMate
100.
"
100 input X
200 if (0<=X and X<49)
300 Output "you fail"
400 Else if (50<=X and X <70)
500 Output "your grade is" X
600 Output " you did OK"
700 ....
"
What will be printed if the input is 0?
You have input the value of X in line 100. It will then execute line 200.
After line 200 has been executed, if the input value of X = 0, which is the next line the program will execute?
Make a guess from the context if you have to.
The if-then-else statement branches according to the condition tested.
In the case of line 200, it tests the value of x=0, if the condition is true, it will execute the next statement (and then jump to after the endif statement), otherwise it goes to the next else or elseif statement, and so on.
If you need more details, explain where the problem is, or explain how you think it works, so we can better help you.
"
100 input X
200 if (0<=X and X<49)
300 Output "you fail"
400 Else if (50<=X and X <70)
500 Output "your grade is" X
600 Output " you did OK"
700 ....
"
What will be printed if the input is 0?
You have input the value of X in line 100. It will then execute line 200.
After line 200 has been executed, if the input value of X = 0, which is the next line the program will execute?
Make a guess from the context if you have to.
The if-then-else statement branches according to the condition tested.
In the case of line 200, it tests the value of x=0, if the condition is true, it will execute the next statement (and then jump to after the endif statement), otherwise it goes to the next else or elseif statement, and so on.
If you need more details, explain where the problem is, or explain how you think it works, so we can better help you.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.