![]() |
| ||
| Re: arrays proplem for(int i=0 ; i<50 ; i++) you had to use cout<<endl if i is divisble by 10 i.e. 10 elements has been printed.. |
| ||
| Re: arrays proplem it will print 11 elements in first line and 10 in all others... to be more accurate use... for(int i=1 ; i<51 ; i++) |
| ||
| Re: arrays proplem Quote:
if( (i+1)%10 == 0)Because i was started from 0 |
| ||
| Re: arrays proplem this is my answer ; is it right ? # include <iostream> |
| ||
| Re: arrays proplem This works if you don't mind the newline right from the get go. if (i % 10 == 0) |
| ||
| Re: arrays proplem Quote:
I'd suggest removing the coutstatements from the forloops of the assignment statements, they just print 25 across the line, which is not what you want. I removed those cout statements and your code is nearly there. The first line only prints 9 numbers, the rest print 10. |
| ||
| Re: arrays proplem for(int i=1 ; i<51 ; i++) {Double open brace and double close brace? There are 2 ways to choose to print 10 numbers for each line. for (int i=0; i<50; i++) {Orfor (int i=1; i<51; i++) {This one also work toofor (int i=0; i<50; ) { |
| All times are GMT -4. The time now is 7:46 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC