On Dec 27, 2007 4:39 PM, muhammad shoaib <[EMAIL PROTECTED]> wrote:
> this program is not show the right out put which i want . any one help me.out
> put should be llike this
> xxxxxxxxxx
> xxxxxxxxx
> xxxxxxxx
> xxxxxxx
> xxxxxx
> xxxxx
> xxxx
> xxx
> xx
> x
#include <iostream>
using namespace std;
> int main ()
> {
> int i=10, j=10;
> while (i<=10)
> {
> j=10;
>
> while (j<=i)
>
> {
> cout<<"x";
>
> j--;
> }
>
> cout<<endl;
> i--;
> }
> return 0;
> }
I'd use a pair of for loops, with the second loop starting on the
difference between 10 and the value of the iterator of the first loop:
for(int i = 0; i < 10; i++) {
for(int j = 10 - i; j > 0; j--) {
cout << '*';
}
cout << endl;
}
Which gives me this output:
./genex
**********
*********
********
*******
******
*****
****
***
**
*
-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi