?
Solved

Syntax Error

Posted on 2011-03-20
6
Medium Priority
?
337 Views
Last Modified: 2012-05-11
Hi guys: Can any one please tell me why it gives syntax error on that line ? Thanks.
      celsustempValue = calcSensus(getFahrcalcvalue);

--------------------------------------------

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
      double getFahrcalcvalue = 0.00;
      double celsustempValue = 0.00;
      double calcFahr()
            {
                        double FarTemp
                        cout << "Enter Fahrenheit temperature==>";
                        cin >> FarTemp;
                        return(FarTemp);
                  }
      double calcSensus(double CencTemp)
            {
                        double FarTempValue = 0.00;
                        FarTempValue = CencTemp;
                        CencTemp = 50 / 9.0 * (FarTempValue -32.0);
                        return(CencTemp);
                  }

      getFahrcalcvalue = calcFahr();
      celsustempValue = calcSensus(getFahrcalcvalue);
      cout << "Celsius temperature==>" << celsustempValue << endl;
      system("pause");
      return 0;
}  
0
Comment
Question by:mustish1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 800 total points
ID: 35177880
Because it can't see your functions since you defined them in the wrong place. You need to define the other functions outside the main function, not in it. Like this.
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

      double calcFahr()
            {
                        double FarTemp
                        cout << "Enter Fahrenheit temperature==>";
                        cin >> FarTemp;
                        return(FarTemp);
                  }
      double calcSensus(double CencTemp)
            {
                        double FarTempValue = 0.00;
                        FarTempValue = CencTemp;
                        CencTemp = 50 / 9.0 * (FarTempValue -32.0);
                        return(CencTemp);
                  }

int main()
{
      double getFahrcalcvalue = 0.00;
      double celsustempValue = 0.00;

      getFahrcalcvalue = calcFahr();
      celsustempValue = calcSensus(getFahrcalcvalue); 
      cout << "Celsius temperature==>" << celsustempValue << endl;
      system("pause");
      return 0;
}  

Open in new window


There may be some other issues, but that's the big one.
0
 
LVL 28

Assisted Solution

by:dpearson
dpearson earned 400 total points
ID: 35177883
Not sure why the error seems to be coming later but it appears you're missing a semi colon here:

      double calcFahr()
            {
                        double FarTemp    <=== missing ;
                        cout << "Enter Fahrenheit temperature==>";

Depending on your compiler it also may not love the nested functions and might require them to be moved outside of main.  But if that's a problem it be a pretty clear error.

Doug
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 35177885
Oh, it's 5/9 not 50/9.
And you don't need the () on the return.
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 32

Accepted Solution

by:
phoffric earned 800 total points
ID: 35177889
Try placing the two functions in main() just above main. This compiles:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double calcFahr()
{
   double FarTemp;
   cout << "Enter Fahrenheit temperature==>";
   cin >> FarTemp;
   return(FarTemp);
}

double calcSensus(double CencTemp)
{
   double FarTempValue = 0.00;
   FarTempValue = CencTemp;
   CencTemp = 50 / 9.0 * (FarTempValue -32.0);
   return(CencTemp);
}

int main()
{
   double getFahrcalcvalue = 0.00;
   double celsustempValue = 0.00;


   getFahrcalcvalue = calcFahr();
   celsustempValue = calcSensus(getFahrcalcvalue); 
   cout << "Celsius temperature==>" << celsustempValue << endl;
   // system("pause");
   return 0;
}

Open in new window

0
 
LVL 32

Expert Comment

by:phoffric
ID: 35177892
Factor of 10 off:
CencTemp = 50 / 9.0 * (FarTempValue -32.0);

Open in new window

Try:
CencTemp = 5/ 9.0 * (FarTempValue -32.0);

Open in new window

0
 

Author Closing Comment

by:mustish1
ID: 35177919
Thanks to every body.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question