Anyway, I've started out on C++ and I had some questions.
The first assignment I had to do was to make a program using if statements:
CODE
#include <iostream>
using namespace std;
int main() // Most important part of the program!
{
int points; // Need a variable...
cout<<"Please input your number of points: "; // Asks for number of points
cin>> points; // The input is put in points
cin.ignore(); // Throw away enter
if ( points < 25 ) { // If the points is less than 25
cout<<"Sorry you have too few points to qualify!\n"; // Just to show you it works...
}
else if ( points == 25 ) { // I use else just to show an example
cout<<"Good job, you met qualification!\n"; // Just to show you it works...
}
else {
cout<<"Wow, you made it with ease!\n"; // Executed if no other statement is
}
cin.get();
}
using namespace std;
int main() // Most important part of the program!
{
int points; // Need a variable...
cout<<"Please input your number of points: "; // Asks for number of points
cin>> points; // The input is put in points
cin.ignore(); // Throw away enter
if ( points < 25 ) { // If the points is less than 25
cout<<"Sorry you have too few points to qualify!\n"; // Just to show you it works...
}
else if ( points == 25 ) { // I use else just to show an example
cout<<"Good job, you met qualification!\n"; // Just to show you it works...
}
else {
cout<<"Wow, you made it with ease!\n"; // Executed if no other statement is
}
cin.get();
}
The next one was doing math with already set integers:
CODE
#include <iostream>
using namespace std;
int main()
{
int x = 10;
int y = 2;
int sum, difference, product, quotient;
sum = x + y;
difference = x - y;
product = x * y;
quotient = x / y;
cout<< "The sum of" << x << "&" << y << "is" << sum << "." << endl;
cout<< "The difference of" << x << "&" << y << "is" << difference << "." << endl;
cout<< "The product of" << x << "&" << y << "is" << product << "." << endl;
cout<< "The quotient of" << x << "&" << y << "is" << quotient << "." << endl;
system ("pause");
}
using namespace std;
int main()
{
int x = 10;
int y = 2;
int sum, difference, product, quotient;
sum = x + y;
difference = x - y;
product = x * y;
quotient = x / y;
cout<< "The sum of" << x << "&" << y << "is" << sum << "." << endl;
cout<< "The difference of" << x << "&" << y << "is" << difference << "." << endl;
cout<< "The product of" << x << "&" << y << "is" << product << "." << endl;
cout<< "The quotient of" << x << "&" << y << "is" << quotient << "." << endl;
system ("pause");
}
I got both of those. The next assignment is to make a calculator from just those two assignments. I'm trying to get a feel for it by googling C++ calculators, but they are all advanced and have functions that I haven't even learned yet.
Any help on how I would start it out and I should be able to manage the rest?