Help Displaying a Celsius temp

I am trying to fix this code and as of right now I'm lost
I am using Microsoft Visual C++ 2010 Express.

This is my Algorithm.
http://i59.tinypic.com/att1d0.jpg


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes
int getFahrenheit();
double calcCelsius(int tempF)


	int main()
{
	int fahrenheit = 0;
	double celcius = 0.0;

	//get input item
	fahrenheit = getFahrenheit();

	//calculate Celsius
	celcius = calcCelsius(fahrenheit);

	//display output item
	cout << fixed << setprecision(0);
	cout << "Celsius: " << celcius << endl;

	system("pause")
	return 0;
}	//end of main function

//*****function definitions*****
int getFahrenheit()
{
	int tempF = 0;
	cout << "Enter Fahrenheit temperature: ";
	cin >> tempF;
	return tempF;
}	//end of getFahrenheit function

double calcCelsius(int tempF)
{
	double tempC = 0.0;
	tempC = 5.0 / 9.0 * (tempF - 32.0);
	return tempC;
}	//end of calcCelsius function


for some reason it keeps giving me a
Error C2144: syntax error: 'int' should be preceded by ';' on line 16 column 1
Error C2143: syntax error: missing ';' before 'return' on line 34 column 1
IntelliSence: expected a ';' on Line 34 Column 2

I have tried to fix both of these problems and no matter what I do I either get more errors or they wont go away...
Last edited on
http://www.eelis.net/iso-c++/testcase.xhtml
Make sure any line numbers you mention in the testcase are correct

line 8: missing semicolon
line 26: missing semicolon

> This is my Algorithm.
> http://i59.tinypic.com/att1d0.jpg
your font choice is awful.
It's not my font choice that is a picture i took from the screen of what i have to do from my book.

double calcCelsius(int tempF);
system("pause");

thanks for pointing that out to me it runs correct now...

One more question is there any type of good apps or programs that I can use to help me with C++ to tell me were my errors are?
Last edited on
¿couldn't you simply select the text?

> good apps or programs that I can use to help me with C++ to tell me were my errors are?
clang (compiler) has nice error messages.
may also want another IDE, like ZinjaI http://zinjai.sourceforge.net/index_en.php?page=portada_en.php
Well I tried selecting the error and were it told me the error was i tried to fix it there but apparently it was wrong place so it wasn't accurate as to were it was telling me...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <iomanip>

// using namespace std;

//function prototypes
int getFahrenheit();
double calcCelsius( int tempF ) ; // **** ; added

int main()
{
    // int fahrenheit = 0;
    // double celcius = 0.0;

    //get input item
    const int fahrenheit = getFahrenheit();

    //calculate Celsius
    const double celcius = calcCelsius( fahrenheit );

    //display output item
    std::cout << std::fixed << std::setprecision(2) << "Celsius: " << celcius << '\n' ;

    // system( "pause" ) ; // **** ; added
    // return 0; // implicit
}   //end of main function

//*****function definitions*****
int getFahrenheit()
{
    int tempF = 0;
    std::cout << "Enter Fahrenheit temperature: ";
    std::cin >> tempF;
    return tempF;
}   //end of getFahrenheit function

double calcCelsius( int tempF )
{
    // double tempC = 0.0;
    // tempC = 5.0 / 9.0 * ( tempF - 32.0 );
    const double tempC = 5.0 / 9.0 * ( tempF - 32.0 );
    return tempC;
}   //end of calcCelsius function 
Topic archived. No new replies allowed.