In: Computer Science
This is continue from my last post. I will need it to be done in the next hour. Please answer in short answer and explain.
What value is contained in the integer variable count after the following statements are executed?
count = 4;
count - count % 4;
count = count * 10;
count = count + 10;
7. What value is contained in the floating point variable area after the following statements are executed?
area = 3.14;
area = area / 10;
area = area * 0.5;
8. What value is contained in the integer variable sum
after the following statements are executed?
sum = 15;
sum = sum % 3;
sum += 500;
sum *= 2;
Ques 6:
The value of count at the end should be 10.
Explanation:
Initially the count is set to 4.
Second line, count = count % 4
evaluates to count = 4%4 = 0
Third line, count = count * 10
evaluates to count = 0 * 10 = 0
Fourth line, count = count + 10
evaluates to count = 0 + 10 = 10.
Ques 7:
The value of area at the end is 0.157000
Explanation:
First line, assigns 3.14 to the area variable.
Then, second line divides the value by 10. which makes it 0.314
Then, third line multiplies 0.5 with the area value.
SO, it becomes 0.157000
Ques 8:
The value of sum will be 1000
Explanation:
sum = 15 assigns 15 to the variable sum.
Then, second line, assigns 15%3 to sum again.
That is 0.
Third line adds 500 to the variable sum, that is 0+500 = 500.
In the last line, sum is multiplied by 2.
So it becomes 500*2 = 1000.
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!