Solved

Syntax Error

Posted on 2011-03-20
6
330 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
6 Comments
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 200 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 26

Assisted Solution

by:dpearson
dpearson earned 100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Accepted Solution

by:
phoffric earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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 …

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now