Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

Compiler errors..lifesaver.

Know the answer? Have a better solution? Share it.
Sign Up Now for FREE!
Join the thousands of students
getting ahead in their classes.
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Rookie
Karma Points: 0
Respect (83%):
Date Posted: 7/23/2008 7:43:42 PM  Status: Live
Compiler errors..lifesaver.
Course Textbook Chapter Problem
N/A N/A N/A N/A
Question Details:

1 #include <iostream>

2 using namespace;

3 /* This program indicates if a triangle is a

4 valid triangle or not. A triangle is a

5 valid triangle, if the sum of any of it’s

6 two sides is greater than the third one.

7 /*

8 int read_numbers(double& , double& , double& );

9 bool triangle (double a, double b);

10 void read_numbers(double& x, double& y, double& z)

11 {

12 cout << "\nEnter the first number: ";

13 cin >> x;

14 cout << "\nEnter the first number: ";

15 cin >> y;

16 cout << "\nEnter the first number: ";

17 cin << z;

18 }

19 int main()

20 {

21 double x, y = 0 , z;

22 bool true_or_false;

23 read_numbers(x, y);

24 If(!x || !y || !z)

25 cout << "Invalid input.";

26 else if(triangle(x, y, z))

27 cout << "this a valid triangle.";

28 else

29 cin << "this is not a valid triangle. ";

30 return;

31 }

32 bool triangle (double x, double y, double z)

33 {

34 if ( x + y > z && x + z > y && z + y > x)

35 return true

36 }
 
 
There are ten compiler errors. can you someone help me with them. thanks.. i have found 7 of them. will rate lifesaver.. need to study for exam.
Line 2: std is missing

Line 10: void should be int

Line 17: Should be cin >> z

Line 24: “If” should be “if”

Line 29: cin should be cout

Line 30: Should be return 0;

Line 35: Needs semicolon

 
 
 

Answers:

Member's Avatar

Expert
Karma Points: 1,043
Date Posted: 7/23/2008 7:48:12 PM  Status: Live
Asker's Rating: Lifesaver   
Response:
 

Line 7:    /* should be */

Line 23:   Needs three arguments

Line 26:   No of arguments does not match




Member's Avatar

Expert
Karma Points: 811
Date Posted: 7/23/2008 11:42:46 PM  Status: Live
Asker's Rating: None Provided    Moderator's Rating: Helpful
Response:
//Dear here is the corrected code, corrected lines are ended with "corrected"
//1
#include <iostream>
//2
using namespace std;//corrected


/* This program indicates if a triangle is a

4 valid triangle or not. A triangle is a

5 valid triangle, if the sum of any of it’s

6 two sides is greater than the third one.

7 */ //corrected

//8
void read_numbers(double& , double& , double& ); //corrected


//9
bool triangle (double a, double b, double c);//corrected


//10
void read_numbers(double& x, double& y, double& z)


{
//11

//12
cout << "\nEnter the first number: ";

//13
cin >> x;

//14
cout << "\nEnter the first number: ";

//15
cin >> y;

//16
cout << "\nEnter the first number: ";

//17
cin >> z; //corrected


//18
}

//19
int main()

//20
{

//21
double x, y = 0 , z;

//22
bool true_or_false;

//23
read_numbers(x, y,z); //corrected

//24
if(!x || !y || !z)

//25
cout << "Invalid input.";

//26
else if(triangle(x, y, z))

//27
cout << "this a valid triangle.";

//28
else

//29
cout << "this is not a valid triangle. ";//corrected

//30
return 0; //corrected
//31
}

//32
bool triangle (double x, double y, double z)

//33
{

//34
if ( x + y > z && x + z > y && z + y > x)

//35
return true; //corrected
else
return false; //corrected
//36
}




By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.