Question

2. Write a program to display the cube of the number up to a given integer....

2.

Write a program to display the cube of the number up to a given integer.

Test Data:

Input number of terms : 5

Expected Output

:

Number is : 1 and cube of the 1 is :1

Number is : 2 and cube of the 2 is :8

Number is : 3 and cube of the 3 is :27

Number is : 4 and cube of the 4 is :64

Number is : 5 and cube of the 5 is :125

0 1
Add a comment Improve this question Transcribed image text
Answer #1
\color{red}\underline{Matlab\;Code:}
n = input("Input number of terms : ");
for i=1:n
    fprintf("Number is : %d and cube of the 1 is :%d\n",i,i^3);
end

Output:

phpdlEPmr.png

Note: Please comment below if you have any doubts. upuote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
2. Write a program to display the cube of the number up to a given integer....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use Matlab to write a program to display the cube of the number up to a...

    Use Matlab to write a program to display the cube of the number up to a given integer. (USE BOTH FOR & WHILE LOOPS PLEASE) Test Data: Input number of terms : 5 Expected Output : Number is : 1 and cube of the 1 is :1 Number is : 2 and cube of the 2 is :8 Number is : 3 and cube of the 3 is :27 Number is : 4 and cube of the 4 is :64...

  • QUESTION 12 Write a program that would prompt the user to enter an integer. The program...

    QUESTION 12 Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube = x...

  • Problem Description: Write s Java program to find and display the product of three integer values...

    Problem Description: Write s Java program to find and display the product of three integer values based on the rue mentioned below it should display the product of the three values except when one of thevalues is 7n that case 7 should not be ingluded in the product and the values to its left also shouid not be included If there is only one value to be considered display that value tself f no values can be included in the...

  • .using while loops(matlab) Write a program to display the sum of the series [ 9 +...

    .using while loops(matlab) Write a program to display the sum of the series [ 9 + 99 + 999 + 9999 ...] Test Data : Input the number or terms :5 Expected Output : 9 99 999 9999 99999 The sum of the series = 111105

  • USING FOR AND WHILE LOOPS-MATLAB) 6. Write a program to display the number in reverse order....

    USING FOR AND WHILE LOOPS-MATLAB) 6. Write a program to display the number in reverse order. Test Data : Input a number: 12345 Expected Output : The number in reverse order is : 54321

  • This Java program reads an integer from a keyboard and prints it out with other comments....

    This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information. Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site. You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same...

  • Write a Visual Basics program that calculates the squares and cubes of the numbers 0 through...

    Write a Visual Basics program that calculates the squares and cubes of the numbers 0 through 5 and displays the resulting values in table format as follow: Number Square Cube 0 0 0 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125

  • 5. Write a program to read in an integer (long) and display all pairs of factors...

    5. Write a program to read in an integer (long) and display all pairs of factors of the input integer. That is, the output must be given as a list of pairs of factors such that the product of each pair is the input integer. Then, print which of these pairs contains only prime numbers (there can be either 1 such pair or none). Note that a. the Scanner class supports a nextLong method to read a long integer, nextBigInteger...

  • 1. Write a program that takes a number as input and check whether the number is...

    1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3.  Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...

  • write a program in java to print all the powers of 2 below a certain number...

    write a program in java to print all the powers of 2 below a certain number and calculate their sum. Make sure your program conforms to the following requirements. 1. Accept the upper limit from the user (as an integer). 2. These numbers grow very fast. make sure the sum variable is of the "long" type. You can assume that the test output will be less that LONG MAX. 3.Print all numbers as a running sum, and finally print their...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT