Write a C program to print the following pattern: * *A* *B*B* *C*C*C* *D*D*D*D* *E*E*E*E*E*E … till n lines where n is the input and it can’t be more than 27.

Questions & AnswersCategory: Programming LanguageWrite a C program to print the following pattern: * *A* *B*B* *C*C*C* *D*D*D*D* *E*E*E*E*E*E … till n lines where n is the input and it can’t be more than 27.
1 Answers
Lokesh Kumar Staff answered 2 years ago

source code: https://gist.github.com/Lokeshkumarbijnor/692dce2abfa4ccd7dcdfcff7a9cc8575

#include 
#include 
using namespace std;

int limit = 5;

int main(){
    cout<<setw(limit+4)<<"*\n";
    for (int i-0; i<limit; i++) {
        cout<<setw((limit+2-i))<<" *";
        for (int j=0; j<=1; j++) {
            cout<<char(i+65)<<"*";
        }
        cout<<"\n";
    }
    return 0;
}