Problem with functions

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 418 Views - Last Post: 18 July 2012 - 02:46 PM Rate Topic: -----

#16 paistehero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-July 12

Re: Problem with functions

Posted 18 July 2012 - 12:39 PM

Currently stuck at...
#include <iostream>    
using namespace std;      

void ticket (float);      
int main ()      
{       

	float age= 0;      
	 

    cout << "Welcome to the Theater!" << endl;      
	cout << "Enter your age: ";      
	cin >> age;      

	cout << "Ticket price: $";    
    
	ticket (age);

    cout <<".00" <<endl;      

	system ("PAUSE");      
	return 0;      
}      

  void ticket (float age)      
{    

	if (age <=12 && age >=62)  
	cout << "2";  
	else 
	cout <<"4";
	
  } 


Thanks all.
Was This Post Helpful? 0
  • +
  • -

#17 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1900
  • View blog
  • Posts: 5,697
  • Joined: 05-May 12

Re: Problem with functions

Posted 18 July 2012 - 12:45 PM

Did you read Jim's tutorials on functions? It's on his signature on every post.
Was This Post Helpful? 0
  • +
  • -

#18 Sublight  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 11-July 08

Re: Problem with functions

Posted 18 July 2012 - 01:39 PM

Reformatting the function to return a value as described in the tutorial is 'good coding practice,' but the real problem is line 28.

Here's a hint.
Was This Post Helpful? 1
  • +
  • -

#19 paistehero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-July 12

Re: Problem with functions

Posted 18 July 2012 - 02:46 PM

I got it! I needed "||" instead of "&&". Thanks all!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2