Learning C++

Venom

Seasoned Veteran
Joined
Sep 12, 2012
Messages
3,798
Reaction score
0
FP$
0
So Iv'e decided to learn C++ so I can code/program.
I'm learning from a book "C++ without fear 2nd edition".
So far I have made a temperature conversion console program, Celsius to Fahrenheit it is my first ever c++ program and is attached, Feedback is appreciated.

Thanks. 🙂

Download Program: http://blogpromotion.net/projectdennis/ ... verter.zip

DLL File: http://www.dll-files.com/dllindex/dll-f ... l?msvcr110

Source Code:

Code:
// convert.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>;
using namespace std;
 
int main() {
        double ctemp, ftemp;
 
        cout << "================= Celsius To Fahrenheit Temperature Converter =================\n\n\n";
        cout << "Please Input a Celsius Temperature and press ENTER: ";
        cin >> ctemp;
        ftemp = (ctemp * 1.8) + 32;
        cout << "\n";
        cout << "Fahrenheit Temperature is: " << ftemp;
        cout << "\n\n";
 
        system("PAUSE");
        return 0;
}
 
As you have compiled your program I cannot tell you how good the code is or anything, so next time could you please upload an uncompiled version as well? I also ask this as I am not too happy about running random programs on my computer, just encase...

However, maybe you could extend it by adding a menu asking whether you would like to do Celsius -> Fahrenheit or Fahrenheit -> Celsius.
 
You forgot to include the .DLLs..anyway, yes, please include source code next time so I can examine before I run.
 
I recommend not using system calls. That is bad practice -- also, next time...include the DLL file right in the same zip file as the executable.
 
You mean the system pause?.

But it crashes without It. 🙁

Also How can I compile for 32 bit?, Im using visual studio 2012.
 
Your program should work fine on both architectures. To stop it crashing, try having the program look for user input when it reaches the end of the file, when it receives input, have it exit.
 
Dennis said:
You mean the system pause?.

But it crashes without It. 🙁

Also How can I compile for 32 bit?, Im using visual studio 2012.
Ah, system("PAUSE") I remember this. 😀
Without it the console program just closes?
Well, technically speaking, you shouldn't use system("PAUSE").
But I know what you mean. It's okay when you're just learning.
At least that's what my teacher told me in our first C++ lesson.
In the future you can write code to decide whether to run the program again or whether to close it on request of the user. But don't worry yourself about this at this stage. Well done for making your first program. :great: It's always nice to see fellow programming enthusiasts. 😀
 
Well, yes, it is OK to use whilst learning, but note that a system call like that will only work on windows, so if you're wanting to distribute to multiple operating systems, you'll need to exnay that system call and use a different method to check for something before exiting. Maybe learn functions and make a function that will stay open until a condition is met (while loop) that checks to see if the user wants to add more input, change an option, etc and only close upon receiving, "exit"... Good luck, Dennis!
 
Thankyou. 🙂

In writing a console based hacking game from scratch.

so far ive Done the login and some of file loading screen.<br /><br />-- 07 Mar 2013, 00:44 --<br /><br />People say "You cant learn as you code" "You cant be creative and experiment" "You shouldnt do that Its harder stupid noob" 🙁
 
Dennis said:
Thankyou. 🙂
People say "You cant learn as you code" "You cant be creative and experiment" "You shouldnt do that Its harder stupid noob" 🙁

lol. I guess they have no idea about programming. Learning through experimenting is much better approach than learning theoretically from books.

Good luck Dennis. Nice work.
 
kavin said:
Dennis said:
Thankyou. 🙂
People say "You cant learn as you code" "You cant be creative and experiment" "You shouldnt do that Its harder stupid noob" 🙁

lol. I guess they have no idea about programming. Learning through experimenting is much better approach than learning theoretically from books.

Good luck Dennis. Nice work.
Agreed. The best way to learn is by trial and error.
I've destroyed countless apps in my lifetime. :lol:
But I've also created best sellers on the App Store.
As you play around you learn, you screw up, you create.
Programming is all about creation. How can you create something if you don't play around with it? Creation doesn't exist already. You can't invent something that already exists. So if people expect you to find the answer to everything via the Internet then those people will never be proper programmers. 😉
 
naathyn said:
Curious. Why have you decided to learn C++ over C?
Maybe he's interested in programming for Windows, which is mainly C++/C# based. C and Objective C are more of an Apple language. It's probably best he starts with C++ as C and especially Objective C are considerably more complicated than C++. 😉
 
Quiver said:
naathyn said:
Curious. Why have you decided to learn C++ over C?
Maybe he's interested in programming for Windows, which is mainly C++/C# based. C and Objective C are more of an Apple language. It's probably best he starts with C++ as C and especially Objective C are considerably more complicated than C++. 😉

That's why i love Java. lol. Its "write once, run anywhere".

I wish to learn C# though.
 
kavin said:
Quiver said:
naathyn said:
Curious. Why have you decided to learn C++ over C?
Maybe he's interested in programming for Windows, which is mainly C++/C# based. C and Objective C are more of an Apple language. It's probably best he starts with C++ as C and especially Objective C are considerably more complicated than C++. 😉

That's why i love Java. lol. Its "write once, run anywhere".

I wish to learn C# though.
C# is amazing and is probably one of the best languages to learn as it's fully supported and has a lot of tutorials and built-in libraries. It's also a language still in use today on one of the world's biggest operating systems, so...naturally...everyone's talking about it. Which is good because if you need help there are plenty of places to ask for it. 🙂
 
Quiver said:
naathyn said:
Curious. Why have you decided to learn C++ over C?
Maybe he's interested in programming for Windows, which is mainly C++/C# based. C and Objective C are more of an Apple language. It's probably best he starts with C++ as C and especially Objective C are considerably more complicated than C++. 😉

Maybe he does, maybe he doesn't. Which is why I am asking him. Most of the people I ask this who are just learning C++, just assume it was better than C. Which obviously is not always the case. As you probably know C has a consistent ABI, whereas most C++ programs that use different compilers can't 'talk' to one another.

And I have never heard of C being called an 'Apple' language lol. I know what you mean though. (Objective-C, maybe)
 
I Read that you could do more with c++ and I started reasearching about it a while ago. Im gonna start off with win apps first.
 
Dennis said:
I Read that you could do more with c++ and I started reasearching about it a while ago. Im gonna start off with win apps first.
Good for you. Get Visual Studio. 😀
 
Thanks, Already got vs 2012 Its what Ive been using. 😛

How could i get a console app into a very basic Gui?.

Thanks.<br /><br />-- 19 Mar 2013, 03:38 --<br /><br />Also when I compile a Console app whats the my sql database version for?. Web use I guess.
 
Back
Top Bottom