htaed
Forum Addict
Okay, so i'm trying to learn C++
After researching a bit, i threw together this code.
Now i know i could of not used the n3 and n6 but i wanted to use them so i could total at the end, if that makes any sence to you.
So, is there anyway i could improve that code? make it smaller? simpler?
Thank you.
After researching a bit, i threw together this code.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string fname, lname;
int n1, n2, n3, n4, n5, n6, n7;
cout << "Hello there, please enter your first name:\n";
cin >> fname;
cout << "Okay, how about your last name:\n";
cin >> lname;
cout << "Okay, so your " << fname << " " << lname << endl;
cout << "\nLets do a sum!\n";
cout << "Please enter a number\n";
cin >> n1;
cout << "Okay, " << n1 << " Good, please enter another number:\n";
cin >> n2;
n3 = n1 + n2;
cout << "Righty, So.. " << n1 << " + " << n2 << " = " << n3 << endl;
cout << "\nLets do another quck sum\n";
cout << "Please enter a number:\n";
cin >> n4;
cout << "Please enter another number:\n";
cin >> n5;
n6 = n4 * n5;
cout << "\nOkie Doke, " << n4 << " * " << n5 << " = " << n6 << endl;
cout << "Okay, one last sum!\n";
cout << "So as we said " << n1 << " + " << n2 << " = " << n4 << " and " << n4 << " * " << n5 << " = " << n6 << " right.. so what if we add the totals\n together\n";
n7 = n3 + n6;
cout << "They total to " << n7 << ". Thanks for using my program!\n";
return 0;
}
Now i know i could of not used the n3 and n6 but i wanted to use them so i could total at the end, if that makes any sence to you.
So, is there anyway i could improve that code? make it smaller? simpler?
Thank you.

