The following code displays the following.
*********
********
*******
******
so on…
How would I get it to do the opposite?
Such as:
*
**
***
****
*****
so on…
[code]
int main()
{
//declare variables
const char asterk = '*';
int a = 9;
int b = 0;
while (a %26gt; 0)
{
b = a;
while (b %26gt; 0)
{
cout %26lt;%26lt; asterk;
b = b - 1;
}
a = a - 1;
cout %26lt;%26lt; endl;
}
//end while
return 0;
} //end of main function
Please help with C++ code?
You basically make it display the opposite...
Here's the code...
int main()
{
//declare variables
const char asterk = '*';
int a = 1;
int b = 0;
while (a %26lt; 9)
{
b = a;
while (b %26gt; 0)
{
cout %26lt;%26lt; asterk;
b--;
}
a++;
cout %26lt;%26lt; endl;
}
//end while
return 0;
} //end of main function
Reply:In the declarations, change
int a = 9;
to
int a = 1;
In the first while loop, change
while ( a %26gt; 0 )
to
while ( a %26lt; 10 )
In the line where a is reassigned, change
a = a - 1;
to
a = a + 1;
Reply:change your piece of code to this:
int a,b=0;
while (a %26lt; 9)
{
b = 0;
while (b %26lt; a)
{
cout %26lt;%26lt; asterk;
b = b + 1;
}
a = a + 1;
cout %26lt;%26lt; endl;
}
Reply:[code]
int main()
{
//declare variables
const char asterk = '*';
int a = 9;
int b = 0;
int c = a + 1
while (a %26gt; 0)
{
b = c - a;
while (b %26gt; 0)
{
cout %26lt;%26lt; asterk;
b = b - 1;
}
a = a - 1;
cout %26lt;%26lt; endl;
}
//end while
return 0;
} //end of main function
Use this and you can change the amount by changing the value of a
Reply:Change the line that says "b = a" to "b = 10-a".
I don't know why I bothered answering this really, you rarely give points for your best answers and they always wind up going to a vote.
Reply:reverse the initial value of a and b
change the equation to b=b+1 etc
Reply:What are you telling...........
Reply:changing b=b+1 and a=a+1 also make a%26lt;9 and b%26lt;a
salary survey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment