# Thread: Some help in C++ requested (new to programming)

1. ## Some help in C++ requested (new to programming)

I'm trying to write a program that converts Celsius to Fahrenheit and the reverse. I just started learning C++ so this might not be the most efficient way to write this. I'm experiencing errors at the "else if" and "while" parts (line 24 and 32). Any tips?

Code:

Code:
```#include <iostream>
#include <cmath>
using namespace std;

int whichconversion;
char continue_ques;
double Fahrenheit;
double Celsius;
double newFtemp;
double newCtemp;
void FtoC(double n);
void CtoF(double n);

int main() {
do {
cout << "Choose what you would like to : " << endl;
cout << "1) Convert F to C" << endl;
cout << "2) Convert C to F" << endl;
cin >> whichconversion;
if( whichconversion == 1 ); {
cout << "Enter the F temp you want to convert: " << endl;
cin >> Fahrenheit;
FtoC(Fahrenheit);
}else if( whichconversion == 2); {
cout << "Enter the C temp you want to convert: " << endl;
cin >> Celsius;
CtoF(Celsius);
}
cout << "Would you like to conduct another conversion? (Yes/No)" << endl;
cin >> continue_ques;
}
while ( continue_ques == Yes );
}

void FtoC(double n){
newCtemp = 0.555555555555556*Fahrenheit-32.0
cout << Fahrenheit << "Fahrenheit is equal to " << newCtemp << "Celsius" << endl;
}

void CtoF(double n){
newFtemp = 1.8*(Celsius+32.0)
cout << Celsius << "Celsius is equal to " << newFtemp << "Fahrenheit" << endl;
}```

2. > if( whichconversion == 1 );
Yeah, those trailing ; are bad news.

3. if else statements should not end with ; cause thatll just end that statement

so it should be like this:
Code:
```if( whichconversion == 1 ) {
cout << "Enter the F temp you want to convert: " << endl;
cin >> Fahrenheit;
FtoC(Fahrenheit);
}else if( whichconversion == 2) {
cout << "Enter the C temp you want to convert: " << endl;
cin >> Celsius;
CtoF(Celsius);
}```
Code:
```void FtoC(double n){
newCtemp = 0.555555555555556*Fahrenheit-32.0
cout << Fahrenheit << "Fahrenheit is equal to " << newCtemp << "Celsius" << endl;
}

void CtoF(double n){
newFtemp = 1.8*(Celsius+32.0)
cout << Celsius << "Celsius is equal to " << newFtemp << "Fahrenheit" << endl;
}```
in here u r MISSING ; in the temp variables

4. You might want to understand the concepts of scopes and statements. Statements ends with a semicolon, but keywords that introduce a scope does not (for example, if, do, while).
Also, a function can return a value, like:

Code:
```double CtoF(double n)
{
return 1.8*(Celsius+32.0);
}

double x = CToF(10.0);```
This way, you can move all your variables inside main. Global variables are considered bad.