You are here : Home >> Infosys Archive >> Infosys Pseudo Codes Questions
Q. What will be the output of the following code :
integer a = 984, b=10
float c
c = a / b
print c
A. 984
B. 98.4
C. 98
D. Error
(c)
Explanation : Answer will be like 98.0000, here C is the most suited option.
You are here : Home >> Infosys Archive >> Infosys Pseudo Codes Questions
Q. Predict the output of the given pseudo code if the value of number is 6
number = input()
k = 2
i = 2
while i <=number
k = k * i
i = i +1
end while
write k
A. 1700
B. 1560
C. 1440
D. Error
(c)
Explanation : Answer will be C, 1440. Let’s track the program flow
while (2 <= 6)
{
k = 2*2 -> 4
i = 2+1 -> 3
}
while (3 <= 6)
{
k = 4*3 -> 12
i = 3+1 -> 4
}
while (4 <= 6)
{
k = 12*4 -> 48
i = 4+1 -> 5
}
while (5 <= 6)
{
k = 48*5 -> 240
i = 5+1 -> 6
}
while (6 <= 6)
{
k = 240*6 -> 1440
i = 6+1 -> 7
}
while(7 <= 6) // false
Hence k = 1440.
I LOVE COG, JUST AWESOME CONTENT.
I think its ans is – C1 and C2 and NOT c4
correct ans is b
what they are provided as a answer of this question 18 as d is wrong answer…….
Correct answer is c
here 16. option b is the answer