HOW WOULD PUT THE OUTPUT INTO ROWS AND 4 COLUMS?
Feb 12, 2014 at 1:09am UTC
HOW WOULD PUT THE OUTPUT INTO ROWS AND 4 COLUMS?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <iostream>
using namespace std;
using namespace std;
int main()
{
long unsigned int i,sum=0;
for (i=0;i<1000;i++)
{
if ((i%5==0)|| ( i%3==0) )
{
sum+=i;
cout << sum<<endl;
}
}
cout << endl << endl;
system ("PAUSE" );
return 0;
}
Feb 12, 2014 at 1:21am UTC
Hi @richard9lives
something like this?
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//SomeFormat.cpp
//##
#include <iostream>
using std::cout;
using std::endl;
int main(){
for (int i=0;i<24;i++){
cout<<i<<((i+1)%4==0?'\n' :' ' );
}//end for
return 0; //indicates success
}//end of main
Feb 12, 2014 at 3:15am UTC
Yep, it works.
thank you
Feb 12, 2014 at 3:22am UTC
You are welcome!
Topic archived. No new replies allowed.