Matlab Input & Output Quiz
35 practical questions on interacting with users via the command window, including input, disp, and formatted output with fprintf.
Question 1
Which command prompts the user to enter a number and stores it in variable 'x'?
Question 2
How do you display the text 'Hello World' in the Command Window without the variable name?
Question 3
Which `fprintf` specifier is used to print a floating-point number?
Question 4
How do you request a *string* input from the user?
Question 5
What does the escape character '\n' do in `fprintf`?
Question 6
What is the output of `fprintf('Value: %d', 5.7)`?
Question 7
How do you combine the string 'Age: ' and the number 25 into a single displayed string?
Question 8
What happens if the user presses Enter without typing anything for `x = input('Val: ')`?
Question 9
Which format specifier limits a floating point number to 2 decimal places?
Question 10
What is the difference between `disp` and `fprintf`?
Question 11
How do you print a literal percent sign '%' using `fprintf`?
Question 12
If `name = 'Alice'`, what does `fprintf('Hello %s', name)` output?
Question 13
Which function converts a number to a string for use in `disp`?
Question 14
What does the command `pause` do?
Question 15
How do you display a matrix `A` nicely in the Command Window?
Question 16
What is the result of `input('Prompt')` if the user types `pi`?
Question 17
Which specifier prints a number in exponential notation (e.g., 1.2e+05)?
Question 18
How do you print a backslash character `` using `fprintf`?
Question 19
What does `int2str(10)` return?
Question 20
Can `fprintf` write to a file instead of the screen?
Question 21
What happens if you use `disp` with multiple arguments, like `disp(a, b)`?
Question 22
Which command clears the Command Window text but keeps variables in the workspace?
Question 23
What is the result of `sprintf('Val: %d', 10)`?
Question 24
How do you align text in columns using `fprintf`?
Question 25
What does `input('Prompt', 's')` return if the user types `123`?
Question 26
Which function allows you to display a warning message in orange text?
Question 27
How do you print a single quote `'` inside a `disp` string?
Question 28
What does `mat2str` do?
Question 29
If `x = [1, 2, 3]`, what does `fprintf('%d ', x)` output?
Question 30
What is the purpose of the `error` function?
Question 31
How do you read a single character from the keyboard without waiting for Enter?
Question 32
Which output function is best for creating tabular data in a text file?
Question 33
What does `newline` return in modern MATLAB?
Question 34
How do you suppress the output of an assignment `x = 5`?
Question 35
What is the correct way to print 'Value is 10%'?
