Powered by Blogger.

Search

Saturday, 20 December 2014

C++ programme to print K pattern


//This programme is tested on visual studio 2012//
#include <iostream>
using namespace std;
void main ()
{
    int n,temp,p=1;
cout<<"------------------------------------------------------------------------------\n";
cout<<"This programme will print a K pattern on entering number greater than 3\n";
cout<<"------------------------------------------------------------------------------\n";
    cout<<"Enter Number :- ";
    cin>>n;
    temp=n;
    while(n<3)
    {
    cout<<"Enter Number :- ";
    cin>>n;   
    }
    for(int i=1;i<=n;i++)
    {
        cout<<" *";
        for(int j=1;j<temp;j++)
        cout<<" ";
        cout<<"*";
        cout<<endl;
        temp=temp-1;
    }
    for(int k=1;k<n;k++)
    {
        if(p<n)
        {
        cout<<" *";
        for(int l=1;l<=p;l++)
        cout<<" ";
        cout<<"*";
        cout<<endl;
        p=p+1;
    }
    }
    cout<<"\n\n------------------------------------------------------------------------------\n";
cout<<"Thank You for using.\n\nVisit http://bilalzahid22.blogspot.com/ for more\n";
cout<<"\n------------------------------------------------------------------------------\n";
}

Ditulis Oleh : Unknown // 07:30
Kategori:

0 comments:

Post a Comment

Translate