Try the fastest way to create flashcards
Question

Create a variable myage and store your age in it. Subtract 2 from the value of the variable. Add 1 to the value of the variable. Observe the Workspace Window and Command History Window as you do this.

Solution

Verified
Answered 1 year ago
Answered 1 year ago
Step 1
1 of 5

Let us first create a variable of name myage and store the age 1818 in it by using assignment statement as follows.

>> myage = 18

myage =
    18

As we did not add a semicolon (;) at the end of the statement myage=18, the compiler prints the output as well just after the execution of the statement. If we want to suppress the output, we have to add a semicolon at the end of the statement, like myage = 18;.

Create a free account to view solutions

Create a free account to view solutions

Recommended textbook solutions

MATLAB: A Practical Introduction to Programming and Problem Solving 4th Edition by Stormy Attaway

MATLAB: A Practical Introduction to Programming and Problem Solving

4th EditionISBN: 9780128045251 (1 more)Stormy Attaway
461 solutions
Fundamentals of Database Systems 7th Edition by Ramez Elmasri, Shamkant B. Navathe

Fundamentals of Database Systems

7th EditionISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
961 solutions
Introduction to Algorithms 3rd Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

3rd EditionISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
872 solutions
Introduction to Algorithms 4th Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

4th EditionISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
945 solutions

More related questions

1/4

1/7