Thread: suffix help.

  1. #1
    Registered User
    Join Date
    Nov 2004

    Unhappy suffix help.

    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.

    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:

    #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
    void addition() //function start for addition
       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";
             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;
    //If user inputs [n]
          case 'n':
          cout << "\n";
          default: //validation
          cout << "Uh-Oh...You typed something wrong..Please Try again. Thank You ^-^\n";
    }}while (additional != 'n'); //loops till 'n' is entered
    Last edited by milkyway_sushi; 11-28-2004 at 12:17 AM.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Seattle, WA
    >>Linker error undefined reference to WinMain@16

    Make sure you are compiling as a console application and not a windows GUI. In dev-c++ go to "project options" and under the "general" tab you should see "type:" Change that to Win32 Console
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suffix tree help!
    By wuzzo87 in forum C Programming
    Replies: 6
    Last Post: 09-07-2006, 01:03 AM
  2. Suffix Trees
    By jodders in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2005, 01:45 PM
  3. suffix trees
    By myjay in forum C++ Programming
    Replies: 1
    Last Post: 11-02-2003, 10:07 PM
  4. Suffix Array
    By bondinc in forum C Programming
    Replies: 1
    Last Post: 10-02-2002, 06:43 PM
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 04:23 PM
Website Security Test