Bird
0
0

What is the output of the following MATLAB code?

medium📝 Predict Output Q4 of 15
MATLAB - String Handling
What is the output of the following MATLAB code?
str1 = 'Data';
str2 = 'Science';
result = [str1 ' ' str2];
disp(result);
AecneicS ataD
BDataScience
CData Science
Data Science
Step-by-Step Solution
Solution:
  1. Step 1: Analyze concatenation with space character

    The code concatenates str1, a space ' ', and str2 using square brackets.
  2. Step 2: Understand disp output

    disp prints the concatenated string exactly as 'Data Science' without extra spaces or newlines.
  3. Final Answer:

    Data Science -> Option C
  4. Quick Check:

    Concatenation with ' ' = 'Data Science' [OK]
Quick Trick: Use ' ' inside brackets to add space between strings [OK]
Common Mistakes:
  • Forgetting space character
  • Expecting extra spaces
  • Confusing disp with fprintf

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes