the program should print
1 this one should have six spaces and then 1
22 5 spaces then 2
333 and so on
4444 sum reason when i post here it aligns left
55555
666666
though it prints...
1
22
333
4444
55555
666666

#include <iostream>
using namespace std;

int main()
{
int i,f,d;
d=0;
while(d<=5){
d++;
for (i=1;i<=1;i++){
	for (f=i;f<=d;f++)
		cout << d ;
		}cout << endl;
}

	return 0;
}
VernonDozier commented: Code tags on first post! +8

the program should print
1 this one should have six spaces and then 1
22 5 spaces then 2
333 and so on
4444 sum reason when i post here it aligns left
55555
666666
though it prints...
1
22
333
4444
55555
666666

#include <iostream>
using namespace std;

int main()
{
int i,f,d;
d=0;
while(d<=5){
d++;
for (i=1;i<=1;i++){
	for (f=i;f<=d;f++)
		cout << d ;
		}cout << endl;
}

	return 0;
}

It aligns left because you haven't displayed any blank spaces with cout . If you want it to align right, you need to have another loop that displays blank spaces BEFORE you display the digits.

I don't see you printing the spaces anywhere ? You can use "setw()" and "right" to set a width and then align your output to the right.

I don't see you printing the spaces anywhere ? You can use "setw()" and "right" to set a width and then align your output to the right.

Yes, that will work too. I guess I assumed that the requirement was to use spaces, but the OP never actually says that. My bad. you know what they say about people who assume. :S

kk thanks

I am not really sure what the OP wants to do either .. :) , sometimes I end up suggesting things they haven't heard of yet !

it suppose to print
_____1 the __ is spaces 5 spaces
____22 4 spaces
___333 3 spaces
__4444 so on
_55555
666666

need some advice where to put the space loop

it suppose to print
_____1 the __ is spaces 5 spaces
____22 4 spaces
___333 3 spaces
__4444 so on
_55555
666666

need some advice where to put the space loop

Lines 12 - 15 below.

#include <iostream>
using namespace std;

int main()
{
   int i,f,d;
   d=0;
   while(d<=5){
   d++;
   for (i=1;i<=1;i++){

      for (f = ?; ?; ?)
      {
            cout << " "; // output a space
      }



	for (f=i;f<=d;f++)
		cout << d ;
		}cout << endl;
}

	return 0;
}

Lines 12 - 15 below.

#include <iostream>
using namespace std;

int main()
{
   int i,f,d;
   d=0;
   while(d<=5){
   d++;
   for (i=1;i<=1;i++){

      for (f = ?; ?; ?)
      {
            cout << " "; // output a space
      }



	for (f=i;f<=d;f++)
		cout << d ;
		}cout << endl;
}

	return 0;
}

thank you Vernon problem solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.