Problem in C++

September 27, 2010 at 23:46:13
Specs: c++
how to make a program with this output


5 10 15 20 25
30 35 40 45 50
55 60 65 70 75
80 85 90 95 10

just only 1 for loop


See More: Problem in C++

Report •


#1
October 1, 2010 at 10:42:50
try this coding...i use borland 5.02

#include <iostream.h>
#include <conio.h>

int main ()
{
int x=5,y,n;
n=25;

for (y=1;y<=4;y++)
{
for (x;x<=n;x+=5)
{
cout << x << " ";
}
cout << endl;
n+=25;
}
getch();
return 0;
}


Report •

#2
October 1, 2010 at 11:06:56
lutfi91, don't do someone else's homework. It's rude. It also uses more than one loop.

Report •

#3
October 3, 2010 at 06:49:12
int i;

for(i=5; i <= 100; i += 5) {
	printf("%3d ", i != 100 ? i : 10);
	if(i % 25 == 0) { putchar('\n'); }
}

If 100 was meant to be printed instead of 10, just scrap the bit in printf. :P

-------------------------------------------
I have no aspiration for preaching. ;-)


Report •

Related Solutions


Ask Question