Ok, here\'s the program (alter nothing in main() please). How can I get this to
ID: 3654548 • Letter: O
Question
Ok, here's the program (alter nothing in main() please). How can I get this to work? I will post the errors in comments. #include #include #include using namespace std; // FUNCTION PROTOTYPE FOR read_us_length int read_us_length(int yards,int feet,int inches); // FUNCTION PROTOTYPE FOR convert2inches int convert2inches(int yards,int feet,int inches); // FUNCTION PROTOTYPE FOR convert2metric int convert2metric(int total_inches,int meters,int centimeters); // FUNCTION PROTOTYPE FOR write_metric_length int write_metric_length(int meters,int centimeters); int main() { int yards, feet, inches; // length in yards, feet and inches int total_inches; // total length in inches int meters, centimeters; // length in meters and centimeters read_us_length(yards, feet, inches); total_inches = convert2inches(yards, feet, inches); convert2metric(total_inches, meters, centimeters); write_metric_length(meters, centimeters); return 0; } // DEFINE FUNCTION read_us_length HERE: int read_us_length(int yards,int feet,int inches) { if (yards<0) { cerr<<"Yards cannot be negative!"<<; void main(); } else if (feet<0) { cerr<<"feet cannot be negative!"<<; void main(); } else if (inches<0) { cerr<<"inches cannot be negative!"<<; void main(); } cout<<"FOR READING LENGTHS: "<<; cout<<"Enter yards: "<<; cin>>yards; cout<<"Enter feet: "<<; cin>>feet; cout<<"Enter inches: "<<; cin>>inches; } // DEFINE FUNCTION convert2inches HERE: int convert2inches(int yards,int feet,int inches) { cout<<"Total inches: "<<total_inches<<; } // DEFINE FUNCTION convert2metric HERE int convert2metric(int total_inches,int meters,centimeters) { centimeters=inches*2.54; meters=centimeters/100; } // DEFINE FUNCTION write_metric_length HERE: int write_metric_length(int meters,int centimeters) { cout<<"Number of Centimeters: "<<centimeters<<; cout<<"Number of Meters: "<<meters<<; cout<<"FOR centimeters (B): "<<centimetersB<<; }Explanation / Answer
Going through the errors one at a time: In function ‘int read_us_length(int, int, int)’: convert2metric.cpp:47: error: expected primary-expression before ‘;’ token convert2metric.cpp:48: error: ‘::main’ must return ‘int’ You mean to say "return 0;" instead of "void main()". The latter makes no sense. convert2metric.cpp:52: error: expected primary-expression before ‘;’ token convert2metric.cpp:53: error: ‘::main’ must return ‘int’ Same as before convert2metric.cpp:57: error: expected primary-expression before ‘;’ token convert2metric.cpp:58: error: ‘::main’ must return ‘int’ Same as before convert2metric.cpp:60: error: expected primary-expression before ‘;’ token Get rid of the last "Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.