473,698 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

to print christmas tree using c++

5 New Member
to print christmas tree using c++
Feb 18 '07 #1
2 8612
Ganon11
3,652 Recognized Expert Specialist
Did you have a question?
Feb 18 '07 #2
terminator1
3 New Member
#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <conio.h> //for kbhit
using namespace std;

//declare constants: symbols used for the drawing
const char BLANK = ' ';
const char LEAF = '#';
const char WOOD = '|';
const char EOL = '\n'; //end of line symbol

//declare variables
int height; //height of the tree
int branchLine; //loop counter for each line of the foliage

int main() //draw Xmas tree
{
void getValidHeigth( );
void drawBranches();
void drawTrunk();
cout << "\n\\\\\\INCOMP LETE version: A.N.Other Jan 07\n";
getValidHeigth( );
cout << "\n\n";
drawBranches();
drawTrunk();

while ( !kbhit()); //hold the screen until a key is pressed
return( 0);
}
//TO BE MODIFIED
void getValidHeigth( ) //get valid height for the tree
{
cout << "\nSTUB: Height is set to 6 in this version!";
height = 6;
}
//TO BE MODIFIED
void drawBranches() //draw foliage
{
//assert( TO BE COMPLETED );
void drawABranch();
for ( branchLine = 1; branchLine <= (height - 2); ++branchLine)
drawABranch(); //draw one line of foliage
}
//TO BE MODIFIED
void drawABranch() //draw one line of foliage
{
//assert( TO BE COMPLETED );
//draw the spaces
cout << BLANK; //print a space
//draw the leaves
for ( int leaves( 1); leaves <= branchLine; ++leaves)
cout << LEAF; //print a leaf symbol
cout << EOL; //go to next line
}

//TO BE MODIFIED
void drawTrunk() //draw trunk
{
//assert( TO BE COMPLETED );
}




use dis skeleton program .....
Feb 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

23
63681
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two vars, along with their names. I could easily do this: print "myPlace = %s, myTime = %s" % (myPlace, myTime)
24
2732
by: Rhino | last post by:
I am dabbling with print CSS for the first time and I need some guidance. The web pages on my site look fine - to my untrained eye - when displayed on the monitor in any of the standard browsers. However, I am new to print CSS and am having trouble getting the text on my printed pages to flow correctly. I know that I need a separate CSS for printing than the one I use for displaying on the monitor; I know that is accomplished by having...
1
2476
by: quirdan | last post by:
Hi, I am after some advice about which data structures I should use. I'm developing a program and I am at the point where all the strings are being generated and printed one by one with loops/recursion using printf("%s\n", my_string);. Instead of printing them, I need to sort them in alphabetical order, and record the amount of times a unique string appears. i.e it will print "ABCD 4" because ABCD appeared 4 times. "BCC 1" because BCC...
4
4019
by: mexicandayworker | last post by:
I have this problem I have to program with vb2005. Write a program to calculate the 12 days of christmas. The program requests an integer from 1 to 12 and then lists the gifts for that day along with the cost. The program should also give the costs for all 12 days ($72,608.00). If bad data is supplied the program should display a message box to the user and NOT perform any calculations. If the data is good the calculations should be performed...
4
9795
by: viperman5000 | last post by:
Using for loops, how would you generate a Christmas Tree using *'s. Also, the size depends on the user's input (size). Any help would be greatly appreciated, as my grade depends on it.
8
3415
by: Bert | last post by:
How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others. The problem: CHRISTMAS TREES The grade 5 class at the local primary school wants some Christmas tree outlines to colour in for the break-up session. You have to write a program which will ask for an odd number representing the size
16
4517
by: raylopez99 | last post by:
I am running out of printing paper trying to debug this...it has to be trivial, but I cannot figure it out--can you? Why am I not printing text, but just the initial string "howdy"? On the screen, when I open a file, the entire contents of the file is in fact being shown...so why can't I print it later? All of this code I am getting from a book (Chris Sells) and the net. The solution is to be found in the fact that stringbuilder is...
0
1669
by: Now You Know | last post by:
Best Christmas Lights Decoration Sale Installation in Los Angeles 818-386-1022 (These types of Innovative lights will definetly add to your Christmas decor) Here are the tips to use: The most common color combinations appropriate for the Christmas season include red, green and copper lights that denote festivity; blue and green lights for more subdued arrangements; novelty combinations such as blue and red lights; and mauve, blue and...
0
2348
by: Now You Know | last post by:
Best Christmas Lights Decoration Sale Installation in Los Angeles 818-386-1022 (These types of Innovative lights will definetly add to your Christmas decor) Here are the tips to use: The most common color combinations appropriate for the Christmas season include red, green and copper lights that denote festivity; blue and green lights for more subdued arrangements; novelty combinations such as blue and red lights; and mauve, blue and...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.