Skilled Illusionist
- Joined
- Nov 21, 2012
- Messages
- 390
- Reaction score
- 213
I don't know if this has been asked before (and if it has, my bad) but I'm freshly starting some C++ developmental skills, and from everyone I've been told to start on small projects, and learn as you go. Again, if you have any other plausible ideas to build my knowledge on this language.. let me know.
I've been following a couple of tutorials too, helping myself learn the basics.. and I've built a program (a simple text-based calculator) all from my own knowledge, with a couple basic tweaks. I did a bit of simple declaration throughout it too.. but yeah.
Of course, it isn't the best. Extremely shakey at the best of terms. But, can anyone just give me simple ideas to do? Perhaps an alarm clock kind of thing, or maybe a schedule? Something that I could get help on from the person creating the project idea.. in all reality.
Again, thanks for your help.
I've been following a couple of tutorials too, helping myself learn the basics.. and I've built a program (a simple text-based calculator) all from my own knowledge, with a couple basic tweaks. I did a bit of simple declaration throughout it too.. but yeah.
Code:
/*
* main.cpp
*
* Created on: Feb 2, 2013
* Author: Siles
*/
#include <iostream>
#include <string>
using namespace std;
int GetUserInput()
{
cout << "Please enter an integer: ";
int nValue;
cin >> nValue;
return nValue;
}
char GetMathematicalOperation()
{
cout << "Please enter an operator (+,-,*,or /): ";
char chOperation;
cin >> chOperation;
return chOperation;
}
int CalculateResult(int nX, char chOperation, int nY)
{
if (chOperation=='+')
return nX + nY;
if (chOperation=='-')
return nX - nY;
if (chOperation=='*')
return nX * nY;
if (chOperation=='/')
return nX / nY;
return 0;
}
void PrintResult(int nResult)
{
cout << "Your result is: " << nResult << endl;
}
int main()
{
// Get first number from user.
int nInput1 = GetUserInput();
// Get mathematical operation from user.
char chOperator = GetMathematicalOperation();
// Get second number from user.
int nInput2 = GetUserInput();
// Calculate result.
int nResult = CalculateResult(nInput1, chOperator, nInput2);
// Print result.
PrintResult(nResult);
}
Of course, it isn't the best. Extremely shakey at the best of terms. But, can anyone just give me simple ideas to do? Perhaps an alarm clock kind of thing, or maybe a schedule? Something that I could get help on from the person creating the project idea.. in all reality.
Again, thanks for your help.