Tuesday 31 May 2016

Write a program that prints a triangle of stars

#include<iostream.h>
#include<conio.h>
void star_triangle(int height);
void main()
{
      clrscr();
      int n;
      cout<<"Enter height of triangle: ";
      cin>>n;
      star_triangle(n);
      getch();
}
void star_triangle(int height)
{
      for(int i=0; i<height; i++)
      {
            for(int j=0; j<= i; j++)
                  cout<<"*";
            cout<<endl;
      }
}

Share:

0 comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

About Me

My photo
A group of two, with a little hope of helping beginners to learn how to code :)
Powered by Blogger.

Comments

Facebook

Ad Home

Follow Us

Random Posts

Sponsor

Recent Posts

Header Ads

Popular Posts

Copyright © Functions in C++ | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com | Distributed By Blogger Templates20