Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: (C++) Whats wrong with this? (C++)  (Read 1132 times)

0 Members and 1 Guest are viewing this topic.
(C++) Whats wrong with this? (C++)
« on: July 18, 2006, 04:46:12 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
This program converts Temperatures from degrees Celsius to degrees from Fahrenheit but when I try to compile it with Dev C++. I get these errors.
Quote
C:\Dev-Cpp\Conversion.cpp: In function `int main(int, char**)':
C:\Dev-Cpp\Conversion.cpp:34: error: expected `;' before ':' token
C:\Dev-Cpp\Conversion.cpp:34: error: expected primary-expression before ':' token
C:\Dev-Cpp\Conversion.cpp:34: error: expected `;' before ':' token

Here's the source code:

Code: [Select]
//
// Conversion.cpp
// Converteert temperaturen van graden Celsius
// naar graden Fahrenheit:
// Fahrenheit = Celsius * (212 - 32)/100+32
//
#include <stdio.h>
#include <iostream.h>

int main(int nNumberofArgs, char* pszArgs[])
{
    //Temperatuur in graden Celsius invoeren
   
    int nCelsius;
    cout << "Enter the temperature in Celsius:";
    cin >> nCelsius;
   
    // De conversiefactor voor Celsius
    // Naar Fahrenheit berkenen
   
    int nFactor;
    nFactor = 212 - 32;
   
    // Conversiefactor gebruiken om waarden
    // van Celsius naar Fahrenheit om te zetten
   
    int nFahrenheit;
    nFahrenheit = nFactor * nCelsius/100 + 32;
   
    // Het resultaat op het beeldscherm tonen
    cout << "Fahrenheit value is:";
    cout << nFahrenheit;
   
    return 0:
}
Logged

Ben

Re: (C++) Whats wrong with this? (C++)
« Reply #1 on: July 18, 2006, 04:48:53 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 437
It strikes me that you've used a real colon after return 0 instead of just a semi-colon.

If something doesn't work, it's usually a good idea to check for typos :D.
Logged
Want a place to upload your sprites and games for FREE? Look no further than GameDevotion
Re: (C++) Whats wrong with this? (C++)
« Reply #2 on: July 18, 2006, 04:51:35 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Code: [Select]
return 0: is your problem. That should be a semicolon (;), not a colon (:).

Also, your conversions are wrong.

F to C = (F - 32) / 1.8
C to F = (F * (9 / 5)) + 32
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: (C++) Whats wrong with this? (C++)
« Reply #3 on: July 18, 2006, 05:13:36 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
Thanks for your help guys! it works now =D
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.057 seconds with 42 queries.