By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

to print christmas tree using c++

P: 5
to print christmas tree using c++
Feb 18 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 3,652
Did you have a question?
Feb 18 '07 #2

P: 3
#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\\\\\\INCOMPLETE version: A.N.Other Jan 07\n";
cout << "\n\n";

while ( !kbhit()); //hold the screen until a key is pressed
return( 0);
void getValidHeigth() //get valid height for the tree
cout << "\nSTUB: Height is set to 6 in this version!";
height = 6;
void drawBranches() //draw foliage
//assert( TO BE COMPLETED );
void drawABranch();
for ( branchLine = 1; branchLine <= (height - 2); ++branchLine)
drawABranch(); //draw one line of foliage
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

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

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

Post your reply

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