Hi friends

i had a assignment to make this c++ program

output

f e d c b a 
  e d c b a 
    d c b a
      c b a 
        b a
          a

i have created this program using this code

# include <iostream.h>
  # include <conio.h>
  void main(void)
  {
char x[6];
  int m=0;
  int n=70;
  int z=0;
  int p=32;
  int b=1 ;
  while(m<6)
  {
  x[m]=n;

  n=n-1;
  m++;

  }
 while(z<6)
  {

  int f=0;
    while(f<6)
    {

    cout<<x[f];
    x[z]=p;
    cout<<x[z];
    f++;
    }
cout<<endl;
    z++;
    }

    }




but its output is 




    f e d c b a 
        d c b a
          c b a 
            b a
              a

if somebody help me than i will be very thankful to you

Regards

You don't need arrays or while loops. Just use three simple for loops. The first counts the number of rows, which is 6. The second displays space(s) to move the cursor on the screen, and the third displays the letters in reverse order that they appear in the alphabet.

loop counts from 0 to 6 // you need 6 rows of data on the screen
   loop counts from 0 until it reaches the value of first counter
      display a space
   loop counts from 'F' - value of first counter, down until it reaches 'A'
       display char value of the counter
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.