2 Replies - 6696 Views - Last Post: 06 April 2012 - 12:13 PM Rate Topic: -----

#1 19HD93  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-April 12

Need Help with ASCII Art Loop Program in C++?

Posted 06 April 2012 - 10:34 AM

Okay so im very new at c++ and im making a program that prints a clown head on top of a base. Now my objective is to have the program print the amount of clown that it's asked for, in this case it's going to be between 2-8. I am using integer N to ask for how many clown heads i want, i also need to make it so that it gives an error when you put a number that is not between 2-8,m but i'll try to figure that out my self. What i am having trouble with is coming up with the loop statements so that it can print the clown heads, this might be a really easy question, but again i am really new to the world of c++. if you can help thank you very much! Here is what i have so far.

#include<iostream>

using namespace std ;

void MakeOneClown () ;
void MakeBase() ;

int main()
{
   int N ;

   cout << " This program has a spring theme." << endl ;
   cout << " It uses SCII art to make a stack of carnival clowns." << endl ;
   cout << " You may request a stack containing between 2 and 8 clowns." << endl ;
   cout << endl ;
   cout << " How many clowns would you like to see? ===>" << endl ;
   cin >> N ;

   MakeOneClown() ;
   MakeBase() ;
}

/* ************************************************************** */
void MakeOneClown ()
{
   cout <<"	    0_\n" ;
   cout <<"	      \\`.     ___\n" ;
   cout <<"	       \\ \\   / __>0\n" ;
   cout <<"	   /\\	/  |/' /\n" ;
   cout <<"	  /  \\/   `  ,`'--.\n" ;
   cout <<"	 / /(___________)_ \\ \n" ;
   cout <<"	 |/ //.-.   .-.\\\\ \\ \\ \n" ;
   cout <<"	 0 // :@ ___ @: \\\\ \\/ \n" ;
   cout <<"	   ( o ^(___)^ o ) 0\n" ;
   cout <<"	    \\ \\_______/ /\n" ;
   cout <<"   jgs    \'._______.\' \n" ;
      
}

/* ************************************************************** */

void MakeBase()
{
    cout <<"	    |||||||||||||||\n" ;
    cout <<"	 |||||||||||||||||||||\n" ;
    cout <<"   |||||||||||||||||||||||||||\n" ;
    cout <<"|||||||||||||||||||||||||||||||||\n" ;
       
}

/* ************************************************************** */



Is This A Good Question/Topic? 0
  • +

Replies To: Need Help with ASCII Art Loop Program in C++?

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1155
  • View blog
  • Posts: 2,534
  • Joined: 05-May 05

Re: Need Help with ASCII Art Loop Program in C++?

Posted 06 April 2012 - 11:45 AM

Here's something that should help. This also looks helpful. Instead of solely using print statements, I'd suggest printing your pattern in a 2D array since it's the equivalent of a graph/grid. It's a lot of easier to visualize things that way. I don't know how much help one can offer without writing code. It's pretty straightforward. Perhaps you should start out by trying to create a rectangle or triangle first.
Was This Post Helpful? 0
  • +
  • -

#3 19HD93  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-April 12

Re: Need Help with ASCII Art Loop Program in C++?

Posted 06 April 2012 - 12:13 PM

okay so i got it too print the number of clowns i ask it too. now im trying to figure out how to make an if statement so when i enter something higher than eight and lower than two it gives a error message that says "Negative: bad value."

heres my updated code :
#include<iostream>

using namespace std ;

void MakeOneClown () ;
void MakeBase() ;

int main()
{
   int N ;

   cout << " This program has a spring theme." << endl ;
   cout << " It uses ASCII art to make a stack of carnival clowns." << endl ;
   cout << " You may request a stack containing between 2 and 8 clowns." << endl ;
   cout << endl ;
   cout << " How many clowns would you like to see? ===>";
   cin >> N ;
   for(int i = 0; i < N; i++)
     {  
      	MakeOneClown ();
     }  
   MakeBase();
   return 0 ;
}

/* ************************************************************** */
void MakeOneClown ()
{
   cout <<"	    0_\n" ;
   cout <<"	      \\`.     ___\n" ;
   cout <<"		\\ \\	/ __>0\n" ;
   cout <<"	   /\\	/  |/' /\n" ;
   cout <<"	  /  \\/   `  ,`'--.\n" ;
   cout <<"	 / /(___________)_ \\ \n" ;
   cout <<"	 |/ //.-.   .-.\\\\ \\ \\ \n" ;
   cout <<"	 0 // :@ ___ @: \\\\ \\/ \n" ;
   cout <<"	   ( o ^(___)^ o ) 0\n" ;
   cout <<"	    \\ \\_______/ /\n" ;
   cout <<"   jgs	\'._______.\' \n" ;

 }

/* ************************************************************** */

void MakeBase()
{
    cout <<"	   |||||||||||||||\n" ;
    cout <<"	|||||||||||||||||||||\n" ;
    cout <<"	 |||||||||||||||||||||||||||\n" ;
    cout <<"	|||||||||||||||||||||||||||||||||\n" ;

}

/* ************************************************************** */

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1