output formatting [was: Help!....]
can some1 help mi... i really cannot do this
please help ty...
Print the following output using one cout << "*"; and one cout << "#"; statements ONLY. You can include the answer along with Question 3.
*#*#*#*#*#
#*#*#*#*#*
*#*#*#*#*#
#*#*#*#*#*
*#*#*#*#*#
#*#*#*#*#*
*#*#*#*#*#
#*#*#*#*#*
*#*#*#*#*#
#*#*#*#*#*
but my code can only make this... can some1 teach me how to make this!!! please
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
*#*#*#*#*#
please help...ty!!!
*#*#*#*#*#
# 1 Re: output formatting [was: Help!....]
Assignment time again?
I'll give a hint:
You have even and odd lines.
(lineNo % 2) == 0 means even line
(lineNo % 2) == 1 means odd line
Don't forget: you can break out the cout statements into functions...
Rune
# 2 Re: output formatting [was: Help!....]
This function seems to meat conditions:
void display()
{
for( int row = 0; row < 10; ++row)
{
for( int col = 0; col < 10; ++col)
{
if(((row % 2) == 0 && (col % 2) == 0) ||
((row % 2) != 0 && (col % 2) != 0))
{
cout << "*";
}
if(((row % 2) == 0 && (col % 2) != 0) ||
((row % 2) != 0 && (col % 2) == 0))
{
cout << "#";
}
}
cout << endl;
}
}
Viorel at 2007-11-11 21:01:59 >

# 3 Re: output formatting [was: Help!....]
This function seems to meat conditions:
void display()
{
for( int row = 0; row < 10; ++row)
{
for( int col = 0; col < 10; ++col)
{
if(((row % 2) == 0 && (col % 2) == 0) ||
((row % 2) != 0 && (col % 2) != 0))
{
cout << "*";
}
if(((row % 2) == 0 && (col % 2) != 0) ||
((row % 2) != 0 && (col % 2) == 0))
{
cout << "#";
}
}
cout << endl;
}
}
Thanks dude...
btw wat is % used for?
# 4 Re: output formatting [was: Help!....]
Assignment time again?
I'll give a hint:
You have even and odd lines.
(lineNo % 2) == 0 means even line
(lineNo % 2) == 1 means odd line
Don't forget: you can break out the cout statements into functions...
Rune
Thanks dude...
btw
Don't forget: you can break out the cout statements into functions...
means?... i dun quite understand...
# 5 Re: output formatting [was: Help!....]
Thanks dude...
btw wat is % used for?
In C++, "%" is an operator that determines the remainder when the first operand is devided by the second.
Fragments like
if((row % 2) != 0)
{
// row is odd: 1, 3, 5, etc.
}
else
{
// row is even: 0, 2, 4, etc.
}
can be used to execute different actions according to the parity of the "row" value.
Alternatively, some programmers prefer to use "if(row & 1) ..." instead.
Viorel at 2007-11-11 21:05:02 >

# 6 Re: output formatting [was: Help!....]
Thanks dude...
btw
Don't forget: you can break out the cout statements into functions...
means?... i dun quite understand...
void printAsterisk()
{
cout << "*";
}
void printPound()
{
cout << "#";
}
void newLine()
{
cout << endl;
}
void printEvenLine()
{
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
newLine();
}
void printOddLine()
{
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
printPound();
printAsterisk();
newLine();
}
void main()
{
printEvenLine();
printOddLine();
printEvenLine();
printOddLine();
printEvenLine();
printOddLine();
printEvenLine();
printOddLine();
printEvenLine();
printOddLine();
}
Technically, this meets the requirement, although I'm quite sure it's not what your teacher intended... :D
Rune
# 7 Re: output formatting [was: Help!....]
wow... thanks every1.... :)
# 8 Re: output formatting [was: Help!....]
*****
****
***
**
*
how are you gonna make this by use for loop...
can any1 help... ty
# 9 Re: output formatting [was: Help!....]
not much to it, make a for loop with a cout statement. What do you have so far that we can help you to finish?
jonnin at 2007-11-11 21:09:06 >

# 10 Re: output formatting [was: Help!....]
I think frozenboy need to work this out by himself. After all, an assignment should be done by the assignee, right?
Hint: A for loop inside a for loop.
Rune
# 11 Re: output formatting [was: Help!....]
Yeah, I agree. Let him do his own homework.
Danny at 2007-11-11 21:11:12 >

# 12 Re: output formatting [was: Help!....]
Technically, this meets the requirement, although I'm quite sure it's not what your teacher intended... :D
Rune
ya never know...might get some creativity points. :p
rssmps at 2007-11-11 21:12:15 >

# 13 Re: output formatting [was: Help!....]
yo every1...
4get to reply to this forum... haha yesterday got everything right...
so ty for ur encouragement