i was wondering how to make a person to chose beween two things with the if statment? for example convtering to celsius or converting to fahrenheit.

would this work?

void FahrenheittoCelcius
void CelciustoFahrenheit

int main()
{
    int personchoice;
    if (personchoice == 1)
{
    void FahrenheittoCelcius;
}
    else 
    void CelciustoFahrenheit;
    return 0;
}

the basic idea is correct but your syntax is all wrong. also i gues that you have to have a means of receiving the user input.

try this after you declare the personchoice int:

cout << "Type 1 to convert fahrenheit to celsius";

and then the following statement

cin >> personchoice;

of course you must include the header file as well. do this before you create the function prototypes.

#include <iostream>
using std::cin;
using std::cout;

now for your method invocation. it is wrong.
this is how you call them:

FahrenheittoCelsius();

in addition your function prototype is wrong too.

void FahrenheittoCelsius();

there are empty brackets at the end of the function prototype to indicate that FahrenheittoCelsius receives no arguments.

and lastly a software design question.
I think your two functions should receive arguments. in the function they are to be converted to the output. which brings me to another point. are you sure that your functions return void? if they convert say to celsius should you not return the celsius?

and now the really last.

just in case you have forgotten. you cannot just write a prototype. you must write a function for each prototype. just putting a prototype which says void FahrenheittoCelsius() is not enough. you must write a function with the code which does the actual converting.

okay thx for the very helpful tip :) i needed this because i am trying to make a temp converter.
this is what i got so far, the first to steps works but then it just repeats the first step.
this is the script:

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

int getChoice();
int CelciustoFahrenheitInput();
int CelciustoFahrenheit();
int FahrenheittoCelciusInput();
int FahrenheittoCelcius();



int main()
{
    
    int choice;
    do{ 
        choice = getChoice();
        if( choice == 1 ) CelciustoFahrenheitInput();
        else if (choice ==2) FahrenheittoCelciusInput();
        if ( choice > 2 || choice < 1)
        cout << "Please enter a valid number."<<endl;
    } while ( choice !=3); 

}

int getChoice()
{
    int x;
    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    cout <<"1-To convert Celcius to Fahrenheit\n";
    cout <<"2-To convert Fahrenheit to Celcius\n";
    cout <<"3-To quit\n\n";
    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    cout << "\nPlease enter number for your choice \n}--> ";
    cin >> x;
    return x;
}


int CelciustoFahrenheitInput()

{
     int c;
     cout << "\nEnter the number you wish to convert into Fahernheit below" <<endl;
     cin >> c;
     int CelciustoFahrenheit();
}
     
int CelciustoFahrenheit()
{
    int c;
    int answer1 = 0;
    answer1 ==(9/5)*c+32;
    cout << c <<"Fahrenheit ="<<answer1<<" Celcius"<< endl;
}

int FahrenheittoCelciusInput()

{
     int f;
     cout << "\nEnter the number you wish to convert into Celcius below" <<endl;
     cin >> f;
     int FahrenheittoCelcius();
}
     
int FahrenheittoCelcius()
{
    int f;
    int answer2 = 0;
    answer2 = (5/9)*(f-32);
    cout << f <<"Fahrenheit ="<<answer2<<" Celcius"<< endl;
}
int CelciustoFahrenheitInput()
{  
     //drop the int in the next line.
     //you want to call the function here
     //what this line is doing as written is declaring a function prototype
     int CelciustoFahrenheit();    
}

In addition, it would work best to pass the value of c obtained in that function to the actual function so the function call would look like this after both changes:

CelciustoFahrenheit(c);

You will need to change the fucntion prototype and the first line in the function definition accordingly so that passing the int variable called c is actually accomplished.

Finally finished and works perfect ;) thx for ur help after all i'm only 13 and this is only the seond week i've been learning it :)

you mean as in born thirteen years ago? i must salute you. if you want to be a programmer someday then i hope you do well.

well... i guess he wasn't saying he was only 13 years from when he took his last bath... :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.