How do I write a code that will prompt the user for a positive number, ("max"), and display a table of integers from 1 to "max" with only 5 integers in each row?
(For example: If the user enters "12", It needs to look like this-
1 2 3 4 5
6 7 8 9 10
11 12
1
Expert's answer
2012-10-01T10:44:13-0400
#include<iostream.h>
int max;
void main(){ cout<<"Enter an integer: "; cin>>max; for (int i=1; i<=max; i++){ & cout<<i<<" "; & if (i%5==0) cout<<"\n"; } cout<<"\n"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment