Printing labels using columns and rows Begginer

Im really new to C++ and am trying to write a program to Print this label 3 columns wide and 8 rows down? Any ideas would be much appreciated? at the moment i can only print it 8 rows down while its in a loop?

**********************************
* *
* Mrs Mary Jo Phillip *
* 31 Charles Street *
* Cardiff, Cf23 8XR *
* *
* *
**********************************



Thanks







#include <stdio.h>

void main ()
{
int x,
y;

x=1;
while (x<=8)
{
printf("********************************\n",x);
printf("* *\n",x);
printf("* Mrs Mary Jo Phillips *\n",x);
printf("* 31 Charles Street *\n",x);
printf("* Cardiff, Cf23 8XR *\n",x);
printf("* *\n",x);
printf("* *\n",x);
printf("********************************\n",x);

for (y=1;y<=10;y++)
{
printf("",y);
}
x++;
}

}
Use the #format when uploading code

The only way is to print every line twice, i believe. You could create a function to do that, that is the easiest way i guess.

If you want to learn c++, i recommend to use cin and cout
i need to do it using loops tho? 3 labels across and 8 down?
Yes, but you dont have to use a loop for every single line.

You could do someting like this:

1
2
3
4
5
6
7
8
9
10
void multistring(string text)
{
cout<<text<<"\t"<<text<<"\t"<<text<<endl;
}
...
for (int i=1;i<=8;i++)
{
multistring("..."); //first line
...                        //etc.
}



EDIT: I dont use a seccond loop here, you dont need that. Another way would be by store every line in an array and then use loops
Last edited on
Topic archived. No new replies allowed.