Hi,
I'm doing this little program, and i need help.
well, I want to make the calculator program where you can add more than 2 numbers.
example:
Enter your 1st number:
Enter your 2nd number you want to add to 1st number:
the answer is:
do you want to continue? [y]/[n]?
If yes:
Enter your __th/nd/rd number:
Here is where i need help:
how do i program it so that when a user enters yes, it will display the suffix after it, and the number increases after each loop, till termination.
like for the first time, it will be:
Enter your 3rd number:
2nd time it will be:
Enter your 4th number
Enter your 5th number
etc etc.
ive tried doing it, but... i get an error message saying:
Linker error undefined reference to WinMain@16
here's what i've tried:
Code:#include <iostream> #include <stdlib.h> #include <cmath> using namespace std; // Variables: double number1, number2; //variable declared for basic functions double answer = 0; // variable declared for basic functions and initialised double memory; // variable declared for memory functions double value; // variable declared for memory functions double numba; // variables declared for memory functions double binary; // variables declared for binary functions int numberX; int valueX = 3; char additional; //variable declared for loop [basic functions] char clear2; // variable declared for loop [memory function] string suffix; //function for addition //basic void addition() //function start for addition { //basic system("cls"); //clears screen cout << "*------------*\n"; cout << "| Addition |\n"; cout << "*------------*\n"; cout << "Please Enter 1st Value: "; cin >> number1; cout << "Please Enter 2nd Value: "; cin >> number2; cout << "The Answer is: " << number1 << " + " <<number2 << " = " << number1 + number2 <<".\n"; answer = number1 + number2; //adding additional numbers do { //adding additional number loop begins cout << "\n\n"; cout << "Do you want to continue?[y/n]: "; cin >> additional; switch(additional) { //switch begins //If user inputs [y] case 'y': if (valueX%10 == 1) suffix = "st"; else if (valueX%10 == 2) suffix = "nd"; else if (valueX%10 == 3) suffix = "rd"; else suffix = "th"; cout <<"Enter the" << valueX << suffix << "to add onto the answer."; cin >> numberX; cout << "The Answer is: " << answer << " + " << numberX << " = " << answer + numberX <<".\n"; answer = answer + numberX; break; //If user inputs [n] case 'n': system("PAUSE"); cout << "\n"; break; default: //validation cout << "Uh-Oh...You typed something wrong..Please Try again. Thank You ^-^\n"; }}while (additional != 'n'); //loops till 'n' is entered }