# User Input and Screen Output

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “User Input and Screen Output – 1”.

1. What is the output of the following code?

`error(“Lola !”);`

a) Output is suppressed
b) Syntactical error
c) No such function exists
d) It displays Lola !

2. What is the output of the following code?

`error(‘Dan !’);`

a) No output, it gets suppressed
b) The word Dan ! is displayed
c) No such function
d) Syntactical Error

3. What is the output of the following code?

`error(‘ No !!!!’)`

a) No !!!!
b) No !!!!
c) Logical Error
d) Symbolic error

4. What is the output of the following code?

`error(‘Lola ! \n Dan !’);`

a) Output is suppressed
b) Symbolic error in \n
c)

```    Lola !
Dan !```

d) Lola ! \n Dan !

5. What is the output of the following code?

`MException('Lola!', '%d * %d= Why?', Inf,Inf)`

a) Error due to identifier
b) Error due to Inf
c)

```    MException with properties:
identifier: 'Lola!’
message: 'Inf * Inf= Why?'
cause: {}
stack: [0×1 struct]```

d) No such command

6. What is the output of the following code?

`MException('MATLAB:test', '%d * %d= Why?', Inf,Inf)`

a)

```    MException with properties:
identifier: ‘MATLAB:test’
message: 'Inf * Inf= Why?'
cause: {}
stack: [0×1 struct]```

b)

```    MException with properties:
identifier: “MATLAB:test”
message: 'Inf * Inf= Why?'
cause: []
stack: [0×1 struct]```

c)

```    MException with properties:
identifier: ''MATLAB:test’
message: '%d * %d= Why?'
cause: {}
stack: [0×1 struct]```

d) Error

7. What is the output of the following code?

`disp(‘%d’,Inf);`

a) Inf
b) No such command
c) Error due to too many arguments
d) Syntactical error

8. What is the output of the following code?

`sprintf(‘%d’,5)`

a) 5
b) ‘5’
c) Syntactical error
d) Logical error

9. What is the output of the following code?

`warning(‘Pikapi !’)`

a) Warning: ‘Pikapi !’
b) Warning: Pikapi !
c) Warning: ‘Pikapi !’
d) Warning: Pikapi !

10. What is the output of the following code?

```warning('off')
warning('Pikapi !')```

a) No output
b) Warning: Pikapi !
c)

```    Warning: Off
Warning: Pikapi !```

d) Syntactical error

11. What is the output of the following code?

`disp(‘ ‘,lola!’ 2’)`

a) ‘lola!’ 2
b) ‘ ‘lola!’ 2’
c) ‘lola! 2’
d) Error due to multiple arguments

12. How many arguments are given to the above command?

`disp(‘ ‘lola!’ 2’)`

a) Cannot be defined
b) 2
c) 1
d) 0

13. What is the output of the following command?

`sscanf(‘.1 .2 .3’,%d)`

a) []
b)

```
.1
.2
.3```

c)

```
1
2
3```

d) Error

14. The default exponential order for %e and %E is same.
a) True
b) False

15. The disp() command cannot print anything but inputs given within string arguments.
a) True
b) False

16. What is the output of the following code?

`sprint(‘%i’,91293)`

a) 91293
b) Syntactical Error
c) The format specifier does not exist
d) ‘91293’

17. What is the output of the following code?

`sprintf(‘%E’,912)`

a) 9.120000E+02
b) 9.120E+02
c) 9.1200E+02
d) 9.12000E+02

18. What is the output of the following code?

`sprintf(‘%d %d %d’,.1, .2.3)`

a) Error
b) ‘1.000000e-01 2.000000e-01 3.000000e-01’
c) 1.000000e-01 2.000000e-01 3.000000e-01
d) []

19. What is the output of the following code?

`disp({12 })`

a) [12]
b) 12
c) [12 ]
d) Error

20. What is the output of the following code?

`size(‘’)`

a) 0
b) Error
c) 0 0
d) 1 1

21. What is the output of the following code?

`sprintf('%04.2f',2.9121)`

a) ‘2.91210000000000000000’
b) ‘2.91’
c) 2.91
d) Error

22. What is the output of the following code?

`sprintf(); disp();`

a) Error due to disp
b) Error due to sprintf()
c) Both gives an error
d) No output is displayed

23. What is the output of the following code?

`P=disp(234)`

a) Error
b) P=234
c) 234
d)

```     P=
234```

24. How can we influence the disp command with format specifiers?
a) Not possible
b) Via the sprintf() command
c) Use format specifiers as string input
d) Give format specifiers as input only

25. What is the output of the following code?

`disp(“12”)`

a) ‘12’
b) “12”
c) 12
d) Error

26. What is the output of the following code?

`fprintf(“%f”,.123)`

a) .123000
b) %f
c) Error
d) .123

27. What is the size of ans variable after the following code?

```sprintf('23 23')
ans=
’23 23’```

a) 14 bytes
b) 10 bytes
c) Error
d) 1*5