Answer to Question #265847 in C++ for Urooj

Question #265847

Write a program using a for loop to display the cube of the numbers up to an integer entered by the user. Only a single for loop is required for this exercise.


1
Expert's answer
2021-11-15T07:37:09-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE




#include<iostream>


using namespace std;


int main()


{
 //prompt the user to enter an integer
 int my_integer;
 cout<<"\nEnter an integer: ";
 cin>>my_integer;
 cout<<"\nThe following are the cubes of numbers from 1 upto your integer "<<my_integer<<"\n"<<endl;
 for(int i = 1; i<=my_integer;i++)
 {
 	cout<<(i*i*i)<<"  ";
 }
 
 cout<<"\n"<<endl;
  return 0;


}


SAMPLE PROGRAM OUTPUT





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS