CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2010
    Posts
    75

    Red face Convert from fahrenheit to celsius

    Hi
    Good Morning ,
    Got Syntax error in the line (10)


    error C2059: syntax error : ')'

    I Use visual studio 2008

    Here is my code ::


    PHP Code:

    # include <iostream>
    using namespace std;
    int main () {

        
    double ctemp,ftemp;

        
    cout << " Enter the f tempeature ";
        
    cin >> ftemp;

        
    ctemp=(ftemp 32 /1.8.);

        
    cout << " the c tempeature is : "<< ctemp;

        
    system ("PAUSE");

        return 
    0;



  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Convert from fahrenheit to celsius

    there is a . behind the 1.8

  3. #3
    Join Date
    Jul 2010
    Posts
    75

    Re: Convert from fahrenheit to celsius


    Dear Skizmo , i checked and i remove the . but i still get the wrong output

    For example : input 75 F ,, get wrong output 57.2222

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Convert from fahrenheit to celsius

    Code:
    ctemp=(ftemp - 32 /1.8.);
    Which happens first ? (ftemp - 32) or (32 / 1.8) ?

  5. #5
    Join Date
    Jul 2010
    Posts
    75

    Re: Convert from fahrenheit to celsius

    it must ( 32 / 1.8 ) happen first

    is this acceptable statement ?

    ctemp= ( 32 / 1.8 ) ( ftemp-32 );

  6. #6
    Join Date
    Jul 2010
    Posts
    75

    Re: Convert from fahrenheit to celsius

    finally it worked when i changed to only one variable declared ,, thanks

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Convert from fahrenheit to celsius

    it must ( 32 / 1.8 ) happen first

    is this acceptable statement ?

    ctemp= ( 32 / 1.8 ) ( ftemp-32 );
    In fact it should be just like this:
    Code:
    ctemp = (ftemp - 32) * 5 / 9;
    http://www.mathsisfun.com/temperature-conversion.html
    Last edited by Igor Vartanov; February 10th, 2012 at 12:35 PM.
    Best regards,
    Igor

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured