Pseudocode Infosys on Campus Hiring Mock I Question


1.What is the output of following Pseudocode?


Set Character c='7'
switch(c)
    case '1':
        display "No.One"
    case '7':
        display "No.Seven"
    case '2':
        display "No.Two"
    default:
        display "No.Hello"
        break
end-switch


   a) No.OneNo.SevenNo.TwoNo.Hello
   b) No.SevenNo.TwoNo.Hello
   c) No.Seven
   d) No.OneNo.Seven


(b) is the correct option.





2.What is the output of following Pseudocode?


Set Integer res=0
do
    --res
    display res
    res++
while(res>=0)
end do-while


   a) Code will run infinite number of times.
   b) The program will not enter the loop.
   c) Code will execute and value of res will be displayed twice.
   d) Code will execute and value of res will be displayed once.


(a) is the correct option.





3.What is the output of following Pseudocode?


for i=0 to 4
do
    if i==i++ + --i
        then do display i
    end-if
end-for


   a) 2
   b) 3
   c) 0
   d) 1


(c) is the correct option.




4.How many times will "Hi" be displayed?


for m = 0 to 4 do
    for n=0 to 4 do
        display 'Hi'
    end-for
    if(m==2) then
        do break
    end-if
end-for


   a) 15
   b) 1
   c) 2
   d) 8


(a) is the correct option.
Here the first for loop is run at m=0,1,2 because after it will break and inner loop work at n=0,1,2,3,4 then 5'times.
,So total 15 times Hi printed.




5.What is output of the given Pseudocode?


set integer emp_no=101
Set integer salary = 0
while(emp_no = 601)
    salary=salary+600
display salary
end-while


   a) Compile time error
   b) Code execute successfully and nothing is displayed
   c) Code execute successfully and value of salary is displayed once
   d) Code execute successfully and value of salary is displayed infinite number of times.


(d) is the correct option.