How to display a Multiple Choice Question and its correct answer in MATLAB?
From today, we are also starting to take the queries from our followers under MATLAB Query label. Our first query is How to display a Multiple Choice Question (MCQ) and its correct answer in MATLAB? For this query, screen capture of matlab program has been shown in figure-1.
First of all, MCQ with its four options is displayed with the command written in line-3 to line-5. To get the correct answer from the user, we have used the command which is written in line-6. Now to check whether the answer is correct or not, we have used ‘if and else’ condition written in line-7 to line-11. We can execute this program by typing its name on command window i.e. query1 which is shown in figure-2.
After execution of program a message ‘Who is the host of Kaun Banega Crorepati. 1) Salman Khan 2) Shah Rukh Khan 3) Amitabh Bachchan 4) Abhishek Bachchan, Which is the write option: ‘ is displayed on the command window. When user select option-1 it display a message ‘Your Answer is Wrong‘. When user select option-2 it display a message ‘Your Answer is Wrong‘. When user select option-3 it display a message ‘Your Answer is Correct‘. When user select option-4 it display a message ‘Your Answer is Wrong‘.
Hope your query is resolved in this post, if you still have a question about this please leave it in below mentioned comment box. To get regular updates from info4eee subscribe us with your email id and to get facebook notifications Like our Facebook page.
Related MATLAB Programming Post: You may be following post also.