Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 25th, 2008, 1:57 AM   #1
ccppjava
Newbie
 
Join Date: Dec 2008
Posts: 3
Rep Power: 0 ccppjava is on a distinguished road
C++ triangle program

i dunno how to read the height of a triangle and print it out.
ccppjava is offline   Reply With Quote
Old Dec 25th, 2008, 2:03 AM   #2
keung2640
Newbie
 
Join Date: Dec 2008
Posts: 3
Rep Power: 0 keung2640 is on a distinguished road
Re: C++ triangle program

Quote:
Originally Posted by ccppjava View Post
i dunno how to read the height of a triangle and print it out.
#include <iostream>
using namespace std;
int height; 

int main() {  
    while(true){
    	cout <<"Enter the height: ";
    	cin >>height;
        for(int j=0; j<height; cout <<"\n",j++){
                for(int i=0;i<height-j;i++){
                     cout<<" ";
                 }
                 for(int k=0;k<j*2+1;k++){
                     cout<<"*";
                 }
        }  
    }
    return 0;
}
keung2640 is offline   Reply With Quote
Old Dec 25th, 2008, 3:00 AM   #3
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,676
Rep Power: 11 lectricpharaoh will become famous soon enough
Re: C++ triangle program

Quote:
Originally Posted by ccppjava
i dunno how to read the height of a triangle and print it out.
That's nice. Of course, your 'question' is very vague. Is it the reading you want to do, the printing, or both? When you talk of printing, do you mean printing out the height of the triangle, drawing a triangle made of a specific character (like an asterisk) as keung2640 concluded, or do you mean drawing the triangle as a graphical object? If the latter, you need to specify the platform you're working with, as doing many things, such as graphics, is specific to the platform you're using. You'll also need more than just the height if you want to draw it graphically.
__________________
My microwave has settings for snake, gremlin, and puppy.
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hello, I'd like to write a program for my work. blake_jl Community Introductions 13 Nov 23rd, 2007 4:31 PM
Language display in program Prm753 C++ 3 May 30th, 2006 5:45 PM
Help me program this with Watcom! DBZ Other Programming Languages 3 Feb 26th, 2006 9:41 PM
Creating a program to test a program sixstringartist C 8 Jan 21st, 2006 1:15 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC