Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
XCode/C++ Help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Nethfel" data-source="post: 1064261" data-attributes="member: 89124"><p>Actually, you have several bugs:</p><p></p><p></p><p>1) In C++, they have what are called namespaces - it's what allows multiple groupings of classes to have the same actual name for a given class and still be allowed to used within a program (ie: if you wanted to write your own cout class, you'd have to create it within a namespace you create, then you would reference your cout class by namespace, so it would be called mynamespace::cout) In the situation here, the easiest thing to do is to tell the compiler which namespace you plan to use for all function calls there on out. Cout and cin are part of the std namespace. For example, to call cout without announcing which namespace you want prior you would need to call it as std::cout. To quickly solve the problem for your program, before main, but after the includes add a line:</p><p></p><p>using namespace std;</p><p></p><p>2) You're missing a lot of semicolons. Each instruction (except for a very few that you haven't encountered yet, ie: if/then statements since a ';' at the end of the if line would cause the "then" portion to not be conditionally activated and instead run each time the if test code is executed) requires a ';' at the end.</p><p></p><p>Looking at your code, see my marked areas:</p><p></p><p>[code]</p><p>//enter temp in celsius</p><p> int celsius;</p><p> cout << "Enter the tempreture in Celsius:";</p><p>----->cin >> celsius</p><p> </p><p> //calculate conversion factor from celcius to fahr.</p><p> int factor;</p><p> factor = 212 - 32;</p><p> </p><p> //use conversion factor to convert celcious to far.</p><p>----->int fahrenheit</p><p>----->fahrenheit = factor * celsius/100 + 32</p><p> </p><p> //show results</p><p> cout << "fahrenheit value is:";</p><p> cout << fahrenheit << endl;</p><p> </p><p> //wait until user has read results</p><p> system("Pause");</p><p> return 0;</p><p></p><p>[/code]</p><p></p><p>each missing semicolon will cause the compiler to fail on compile and return an error.</p><p></p><p>Hope that helps.</p></blockquote><p></p>
[QUOTE="Nethfel, post: 1064261, member: 89124"] Actually, you have several bugs: 1) In C++, they have what are called namespaces - it's what allows multiple groupings of classes to have the same actual name for a given class and still be allowed to used within a program (ie: if you wanted to write your own cout class, you'd have to create it within a namespace you create, then you would reference your cout class by namespace, so it would be called mynamespace::cout) In the situation here, the easiest thing to do is to tell the compiler which namespace you plan to use for all function calls there on out. Cout and cin are part of the std namespace. For example, to call cout without announcing which namespace you want prior you would need to call it as std::cout. To quickly solve the problem for your program, before main, but after the includes add a line: using namespace std; 2) You're missing a lot of semicolons. Each instruction (except for a very few that you haven't encountered yet, ie: if/then statements since a ';' at the end of the if line would cause the "then" portion to not be conditionally activated and instead run each time the if test code is executed) requires a ';' at the end. Looking at your code, see my marked areas: [code] //enter temp in celsius int celsius; cout << "Enter the tempreture in Celsius:"; ----->cin >> celsius //calculate conversion factor from celcius to fahr. int factor; factor = 212 - 32; //use conversion factor to convert celcious to far. ----->int fahrenheit ----->fahrenheit = factor * celsius/100 + 32 //show results cout << "fahrenheit value is:"; cout << fahrenheit << endl; //wait until user has read results system("Pause"); return 0; [/code] each missing semicolon will cause the compiler to fail on compile and return an error. Hope that helps. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
XCode/C++ Help
Top