Question: I need to do this in C++ Write a code segment that will prompt the user for a positive number, max, and display a table

I need to do this in C++

Write a code segment that will prompt the user for a positive number, max, and display a table of integers from 1 to max. Display only 5 integers in each row. For example, the user enters a max of 12.

1 2 3 4 5

6 7 8 9 10

11 12 So far I haveI have to use a printf

cout << "Enter a positive number: ";

cin >> postable;

if ( postable > 0 )

for ( int x=1 ; postable >= x ; x++)

printf ( "%3d" , x );

I can't get it to only have 5 integers a row.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!