Monday, 29 February 2016

Alphabet pattern using c++


#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{

    //variable declaration
      int x, y, n;
      char ch;
      cout<<"Enter the number of rows -> ";
      cin>>n;
     for(x = 1;x<= n;x++)

    {
       cout<<"\n";
       ch = 'A';

        for(y = 1;y<=x;y++)
      {
            cout<<ch;
            ch++;

        }

    }

}



OUTPUT

Number of rows -> 9

 A
 AB
 ABC
 ABCD
 ABCDE
 ABCDEF
 ABCDEFG
 ABCDEFGH
 ABCDEFGHI

No comments:

Post a Comment