Bird
0
0

What is the output of this MATLAB code?

medium📝 Predict Output Q4 of 15
MATLAB - String Handling
What is the output of this MATLAB code?
str1 = 'Data';
str2 = 'Science';
result = [str1 ' ' str2];
disp(result);
ADataScience
BData Science
CecneicS ataD
DError: Invalid concatenation
Step-by-Step Solution
Solution:
  1. Step 1: Understand string concatenation with spaces

    The code concatenates str1, a space character, and str2 into one string.
  2. Step 2: Predict the output of disp(result)

    The output will be 'Data Science' with a space between the words.
  3. Final Answer:

    Data Science -> Option B
  4. Quick Check:

    Concatenation with space = 'Data Science' [OK]
Quick Trick: Use spaces inside brackets to join words with space [OK]
Common Mistakes:
  • Forgetting space character
  • Expecting automatic spaces
  • Thinking concatenation causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes