Thread: Math Program Problem

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    2

    Math Program Problem

    How do I get the highlighted part in the to say the integer #? I want it to say 17 + 5 = 22 instead of it saying firstInt + secondInt = 22. Can anyone help me?



    http://img710.imageshack.us/img710/9085/cscproblem.png



    Code:
    // ********************************
    
    
    #include <iostream>
    #include <cmath>
    #include <cstdlib>
    #include <string>
    
    
    using namespace std;
    
    
    int main ()
    {
        int x, y, firstInt, secondInt; 
            
        cout << "Hello I'm an arithmetic wizard. I can perform the following" 
        " arithmetic operations on a pair of integars" << endl;
        cout << endl;
        cout << "Addition" << endl;
        cout << "Subtraction" << endl;
        cout << "Multiplication" << endl;
        cout << "Division" << endl;
        cout << "Modulus" << endl;
        cout << endl;
        cout << "Please enter your integers" << endl;
        cout << endl;
        cout << "First Integer >>  ";
        cin >> firstInt; 
        cout << endl;
        cout << "Second Integer >> ";
        cin >> secondInt;
        cout << endl;
        cout << "firstInt + secondInt  =  " << firstInt + secondInt << endl;
        cout << endl;
        cout << "firstInt - secondInt  =  " << firstInt - secondInt << endl;
        cout << endl;
        cout << "firstInt * secondInt  =  " << firstInt * secondInt << endl;
        cout << endl;
        cout << "firstInt / secondInt  =  " << firstInt / secondInt << endl;
        cout << endl;
        cout << "firstInt % secondInt  =  " << firstInt % secondInt << endl;
        cout << endl;
        
        system("pause");
    
    
        return 0;
    }

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Well this is not a mathematical problem,but i problem with the print operation.Be careful to clearly state what is your problem in order to get fast responses(you will get rid of the delay of the person who is willing to answer to understand what really is the problem).

    the solution is
    Code:
     cout << firstInt<<" + "<<secondInt<<"  =  " << firstInt + secondInt << endl;
    In order to get the numbers that are going to be added shown,you need to have then without the double quotes.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    2
    Thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program this math problem
    By rightbrainer in forum C Programming
    Replies: 2
    Last Post: 04-17-2009, 11:12 AM
  2. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 11:53 AM
  3. Basic Math Problem. Undefined Math Functions
    By gsoft in forum C Programming
    Replies: 1
    Last Post: 12-28-2004, 03:14 AM
  4. Math program
    By KneeGrow in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2004, 08:20 AM
  5. Take a look at my program(math problem)
    By Ruflano in forum C++ Programming
    Replies: 3
    Last Post: 03-02-2002, 01:24 PM