Powered by Blogger.

Search

Friday, 19 December 2014

C++ prigramme to print V pattern


//This programme is tested on visual studio 2012//
#include <iostream>
using namespace std;
void main()
{
    int n,t;
    t=1;
cout<<"------------------------------------------------------------------------------\n";
cout<<"This programme will print a V pattern on entering number greater than 1\n";
cout<<"------------------------------------------------------------------------------\n";
    cout<<"Enter number : ";
    cin>>n;
    while (n<=1)
    {
    cout<<"You entered invalid input Try again :\n";
    cout<<"Enter number";
    cin>>n;
    }
    int temp=2*n;
    for(int i=1;i<n;i++)
    {
   
        for(int j=1;j<=t;j++)
        cout<<" ";
        cout<<"*";
        for(int k=1;k<temp-2;k++)
    {
   
        cout<<" ";

}
        cout<<"*";
        cout<<endl;
        t=t+1;
        temp=temp-2;
       
    }
    for(int j=1;j<t;j++)
        cout<<" ";
        cout<<" *";
        cout<<"\n\n------------------------------------------------------------------------------\n";
    cout<<"Thank You for using.\n\nVisit http://bilalzahid22.blogspot.com/ for more\n";
  cout<<"\n------------------------------------------------------------------------------\n";
}

Ditulis Oleh : Unknown // 22:35
Kategori:

0 comments:

Post a Comment

Translate