why i cant move the formula under int main()?

#include <iostream>
#include <stdlib.h>
using namespace std;



double fIntoCm(double dIn)
{
    double dCm;
    dCm = dIn*2.54;
    return (dCm);
}

double fYtoM(double dY)
{
double dM;
dM = dY*0.914;
return (dM);
}

double fOtoM(double dO)
{
double dM2;
dM2 = dO*29.574;
return (dM2);
}


double fMtoKm(double dMl)
{
double dKm;
dKm = dMl*1.61;
return (dKm);
}

double fCmtoIn(double dCm)
{
double dIn;
dIn = dCm*0.394;
return (dIn);
}

double fMtoY(double dM)
{
double dY;
dY = dM*1.094;
return (dY);
}

double fMltoO(double dMl)
{
double dO;
dO = dMl*0.034;
return (dO);
}

double fKmtoMl(double dKm)
{
double dMl;
dMl = dKm*0.621;
return (dMl) ;
}

int main()

{
       cout<< " Welcome to a unit conversion program!" << endl;
       cout<< "" << endl;
       cout<< " Please note the program gives answers to a 3 significant figures accuracy"<< endl;
       cout<< "" << endl;
       lOConv:
       cout<< " Press 1 to show the available royal units  to the metric units conversions list" << endl;
       cout<< "                                                                                " << endl;
       cout<< " Press 2 to show the available metric units to the royal units conversions list" << endl;
       cout<< "                                                                                " << endl;
       cout<< " Press any other key to exit" << endl;
       cout<< "" << endl;
       char cConvtype;
       cin>> cConvtype;

    do
    {
       if(cConvtype == '1')
        {
           char cRConv;
               do
                {
                    cout<< "You have chosen to show  royal units  to metric units conversion list" << endl;
                    cout<< "" << endl;
                    cout<< "Press 1 to convert inches to centimetres " << endl;
                    cout<< "" << endl;
                    cout<< "Press 2 to convert yards to meters " << endl;
                    cout<< "" << endl;
                    cout<< "Press 3 to convert fluid ounces to mililiters" << endl;
                    cout<< "" << endl;
                    cout<< "Press 4 to convert miles to kilometers" << endl;
                    cout<< "" << endl;
                    cout<< "Press 5 to return to the first option screen" << endl;
                    cout<<""<<endl;
                    cin>> cRConv;

                    if(cRConv == '1') {
                              double dAns;
                              double dFans;
                              cout<< "Please input the inches you wish to convert" << endl;
                              cout<< "" << endl;
                              cout<< "Note, the input has to be in inches only, no feet can be converted" << endl;
                              cout<< "" << endl;
                              cin>> dAns;
                              dFans = fIntoCm(dAns);
                              cout<< dAns << " inches converted to centimetres is " << dFans << endl;
                              cout<< "" << endl;
                              char cAns;
                              cout<< "Do you wish to make another conversion? (y/n)" << endl;
                              cin>> cAns;
                              if(cAns == 'y') {

                                  goto    lOConv;

                              }
                              }



                     else if(cRConv == '2') {
                         double dAns2;
                         double dFans2;
                         cout << "Please input the yards you wish to convert" << endl;
                         cout<< "" << endl;
                         cin>> dAns2;
                         dFans2 = fYtoM(dAns2);
                         cout<< dAns2 << " yards converted to meters is " << dFans2 << endl;
                         cout<< "" << endl;
                          char cAns;
                          {
                              cout<< "Do you wish to make another conversion? (y/n)" << endl;
                              cout<< "" << endl;
                              cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }


                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }
                                   }

                         }

                    else if(cRConv == '3') {
                         double dAns3;
                         double dFans3;
                         cout<< "Please input the ounces you wish to convert"<< endl;
                         cout<< "" << endl;
                         cin>> dAns3;
                         dFans3 = fOtoM(dAns3);
                         cout<< dAns3 << " fluid ounces converted to mililimeters is " << dFans3 << endl;
                         cout<< "" << endl;
                          char cAns;
                          {
                              cout<< "Do you wish to make another conversion? (y/n)" << endl;
                              cout<< "" << endl;
                              cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }
                                   }
                                   }


                    else if(cRConv == '4'){
                         double dAns4;
                         double dFans4;
                         cout << "Please input the miles you wish to convert" << endl;
                         cout<< "" << endl;
                         cin >> dAns4;
                         dFans4 = fMtoKm(dAns4);
                         cout << dAns4 << " miles converted to kilometers is " << dFans4 << endl;
                         cout<< "" << endl;
                         char cAns;
                              cout<< "Do you wish to make another conversion? (y/n)" << endl;
                              cout<< "" << endl;
                              cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                    else if(cRConv == '5'){
                         cout<< " You will return to the first option screen " << endl;
                         goto lOConv;
                         }

                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }

                                   }

                }  while (cRConv == '1'&& cRConv == '2' && cRConv == '3' && cRConv == '4' && cRConv == '5');
               }



       if(cConvtype == '2') {
            char cRConv2;

            do{

                    cout<< "You've chosen to show metric units to royal units conversion list" << endl;
                    cout<< "" << endl;
                    cout<< "Press 1 to convert centimetres to inches" << endl;
                    cout<< "" << endl;
                    cout<< "Press 2 to convert metres to yards" << endl;
                    cout<< "" << endl;
                    cout<< "Press 3 to convert mililitres to fluid ounces " << endl;
                    cout<< "" << endl;
                    cout<< "Press 4 to convert kilometers to miles " << endl;
                    cout<< "" << endl;
                    cout<< "Press 5 to return to the first option screen" << endl;
                    cout<< "" << endl;
                    cin>> cRConv2;


                    if(cRConv2 == '1'){

                               double dAns;
                               double dFans;
                               cout<< " Please input the centimetres you wish to convert " << endl;
                               cout<< "" << endl;
                               cout<< "Note: Only centimetres the program does not convert meters and centimetres" << endl;
                               cout<< "" << endl;
                               cin>> dAns;
                               dFans = fCmtoIn(dAns);
                               cout<< dAns << " centimetres converted to inches is " << dFans << endl;
                               cout<< "" << endl;
                               char cAns;
                               cout<< "Do you wish to make another conversion? (y/n)" << endl;
                               cout<< "" << endl;
                               cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                              else {
                                   cout<< "Thanks for using River100's unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }



                               }
                    if(cRConv2 == '2'){
                               double dAns2;
                               double dFans2;
                               cout<< "Please input the meters you wish to convert " << endl;
                               cout<< "" << endl;
                               cin>> dAns2;
                               dFans2 = fMtoY(dAns2);
                               cout << dAns2 << " meters converted to yards is " << dFans2 << endl;
                               cout<< "" << endl;
                                char cAns;
                               cout<< "Do you wish to make another conversion? (y/n)" << endl;
                               cout<< "" << endl;
                               cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }



                               }
                   else  if(cRConv2 == '3'){

                               double dAns3;
                               double dFans3;
                               cout<< "Please input the mililiters you wish to convert" << endl;
                               cout<< "" << endl;
                               cin>> dAns3;
                               dFans3 = fMltoO(dAns3);
                               cout << dAns3 << " mililiters converted to fluid ounces is " << dFans3 << endl;
                               cout<< "" << endl;
                               char cAns;
                               cout<< "Do you wish to make another conversion? (y/n)" << endl;
                               cout<< "" << endl;
                               cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }





                               }
                   else if(cRConv2 == '4'){
                               double dAns4;
                               double dFans4;
                               cout<< "Please input the kilometers you wish to convert" << endl;
                               cout<< "" << endl;
                               cin>> dAns4;
                               dFans4 = fKmtoMl(dAns4);
                               cout<< dAns4 << " kilometers converted to miles is " << dFans4 << endl;
                               cout<< "" << endl;
                               char cAns;
                               cout<< "Do you wish to make another conversion? (y/n)" << endl;
                               cout<< "" << endl;
                               cin>> cAns;
                              if(cAns == 'y') {
                                      goto lOConv;

                              }

                   else if(cRConv2 == '5'){
                        cout<< " You will return to the first option screen " << endl;
                               goto lOConv;
                          }


                              else {
                                   cout<< "Thanks for using this unit conversion program!" << endl;
                                   cout<< "" << endl;
                                   goto lExit;
                                   }

                               }

                    } while (cRConv2 == '1' && cRConv2 == '2' && cRConv2 == '3' && cRConv2 == '4' && cRConv2 == '5');

                }
       else {

            cout<< "The program will now exit" << endl;
            cout<< "" << endl;
            goto lExit;

                      }

                      } while (cConvtype == '1' && cConvtype == '2');

    lExit:
    system("Pause");
    cout<< "" << endl;
    return 0;

}

You can, but functions must be declared before their first use, which means you need to add prototypes for the formula functions before main, and the definitions after main:

#include <iostream>
#include <stdlib.h>
using namespace std;

double fIntoCm(double dIn);
double fYtoM(double dY);
double fOtoM(double dO);
double fMtoKm(double dMl);
double fCmtoIn(double dCm);
double fMtoY(double dM);
double fMltoO(double dMl);
double fKmtoMl(double dKm);

int main()
{
    ...
}

double fIntoCm(double dIn)
{
    double dCm;
    dCm = dIn*2.54;
    return (dCm);
}

double fYtoM(double dY)
{
    double dM;
    dM = dY*0.914;
    return (dM);
}

double fOtoM(double dO)
{
    double dM2;
    dM2 = dO*29.574;
    return (dM2);
}

double fMtoKm(double dMl)
{
    double dKm;
    dKm = dMl*1.61;
    return (dKm);
}

double fCmtoIn(double dCm)
{
    double dIn;
    dIn = dCm*0.394;
    return (dIn);
}

double fMtoY(double dM)
{
    double dY;
    dY = dM*1.094;
    return (dY);
}

double fMltoO(double dMl)
{
    double dO;
    dO = dMl*0.034;
    return (dO);
}

double fKmtoMl(double dKm)
{
    double dMl;
    dMl = dKm*0.621;
    return (dMl);
}

Why? Because C++ demands that functions are defined before they are used but you can define your functions like so.

double fIntoCm(double);

int main()
{
...
}

double fIntoCm(double dIn)
{
     double dCm;
     dCm = dIn*2.54;
     return (dCm);
}

Because C++ demands that functions are defined before they are used

It's important to make a distinction between a declaration and a definition. Only a declaration is required to compile the code, but a definition is required to link it. Prototypes are declarations, they introduce the function signature.

Yeah, my bad. I was wrote the reply too fast.

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.