473,883 Members | 2,453 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 8628
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
63732
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
2754
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
2484
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
4025
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
9804
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
3431
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
4535
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
1682
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
2366
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
9953
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
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
11166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7980
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
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3242
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.