C++/c++

Advertisement


Question
i want 2 make a pyramid of alphabets the output should b-
    A
   A B
 A  B  C
A  B  C  D
like this so plz help me out.

Answer
cout<<"number of characters to be printed";
  int inum,ispace;
  cin>>inum;
  char *temp = new char[inum];
  for (int i =0;i<inum;i++)
  cin>>temp[i];
  int count =0 ;
  ispace = inum;
  while( count<inum)
  {
     
     for(int j = 0;j< ispace;j++)
     cout<<" ";
     for(int i = 0;i<=count;i++)
     {
         cout<<temp[i]<<" ";
     }
     cout<<"\n";
     ispace--;
     count++;
 }

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


rakshitha

Expertise

Difficult questions related to C .

Experience

C ,vc ,opc ,windows CE, ActiveX

Education/Credentials
Masters in electrical engineering

©2016 About.com. All rights reserved.