7th Class Computers Science Programming Concepts Question Bank Programming in QBASIC

  • question_answer
    What will be the output of the following QBASIC code?
    \[\begin{array}{*{35}{l}}    x\text{ }=\text{ }8  \\    IF\text{ (}x\text{ }=\text{ }5\text{) }THEN  \\    ~~~~~PRINT\text{ }''You\text{ }selected\text{ }5''  \\    ELSEIF\text{ (}x\text{ }=\text{ 6) }THEN  \\    ~~~~~PRINT\text{ }''You\text{ }selected\text{ }6''  \\    ELSEIF\text{ (}x\text{ }=\text{ 7) }THEN  \\    ~~~~~PRINT\text{ }''You\text{ }selected\text{ }7''  \\    ELSE  \\    ~~~~~PRINT\text{ }''You\text{ }made\text{ }an\text{ }invalid\text{ }choice''  \\    END\text{ }IF  \\ \end{array}\]
     

    A) You selected 5

    B) You selected 6

    C) You selected 7

    D) You made an invalid choice

    Correct Answer: D

    Solution :

    As the value of x is 8, so only the ELSE part will get executed.


You need to login to perform this action.
You will be redirected in 3 sec spinner