problem

This is a discussion on problem within the C++ Programming forums, part of the General Programming Boards category; [code] #include<iostream> using namespace std; int main() { int e; cout<<"1.Addition"<<endl; cout<<"2.Subtraction"<<endl; cout<<"3.Multiplication"<<endl; cout<<"4.Long Addition"<<endl; cout<<"5.Devision"<<endl; cin>>e; if (e==1) { ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    42

    problem

    [code]
    #include<iostream>
    using namespace std;
    int main()
    {
    int e;
    cout<<"1.Addition"<<endl;
    cout<<"2.Subtraction"<<endl;
    cout<<"3.Multiplication"<<endl;
    cout<<"4.Long Addition"<<endl;
    cout<<"5.Devision"<<endl;
    cin>>e;
    if (e==1)

    {
    cout<<"Welcome to Addition"<<endl;
    int g;
    int b;
    cout<<"Enter the two numbers you want to add "<<endl;
    cin>>g;
    cin>>b;
    int add;
    add = g + b;
    cin.get();
    cout<<g<<" plus "<<b<<" is "<<add<<endl;
    cin.get();
    if (e==2)


    {
    int x;
    int y;
    cout<<"Welcome to subtraction"<<endl;
    cout<<"Enter the two numbers you want to subtract "<<endl;
    cin>>x;
    cin>>y;
    int sub;
    sub = x - y;
    cin.get();
    cout<<x<<" subtract "<<y<<" is "<<sub<<endl;
    cin.get();
    if (e==4)

    {
    int z;
    int q;
    int w;
    int k;
    int f;
    cout<<"Welcome to Long Addition"<<endl;
    cout<<"Enter the five numbers you want to add "<<endl;
    cin>>z;
    cin>>q;
    cin>>w;
    cin>>k;
    cin>>f;
    int ladd;
    ladd = z + q + w + k+ f;
    cin.get();
    cout<<z<<" add "<<q<<" add "<<w<<" add "<<k<<" add "<<f<<" is "<<ladd<<endl;
    cin.get();
    if (e==5)


    {
    cout<<"Welcome to Devision"<<endl;
    int t;
    int g;
    cout<<"Enter the two numbers you want to devide "<<endl;
    cin>>t;
    cin>>g;
    int div;
    div = t / g;
    cin.get();
    cout<<t<<" divided by "<<g<<" is "<<div<<endl;
    cin.get();
    if (e==3)

    {
    cout<<"Welcome to Multiplication"<<endl;
    int i;
    int h;
    cout<<"Enter the two numbers you want to Multiply "<<endl;
    cin>>i;
    cin>>h;
    int mul;
    mul = i * h;
    cin.get();
    cout<<i<<" Multiplied by "<<h<<" is "<<mul<<endl;
    cin.get();

    }
    return 0;
    }
    }
    }
    }
    }
    [code]
    That is a calculator i made i want it so if you press 1 it goes to addition but if i press 2,3,4 it dosent go to the option the screen closes

  2. #2
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Re: problem

    Code:
    #include<iostream>
    using namespace std;
    int main()
    {
       int e;
       cout<<"1.Addition"<<endl;
       cout<<"2.Subtraction"<<endl;
       cout<<"3.Multiplication"<<endl;
       cout<<"4.Long Addition"<<endl;
       cout<<"5.Devision"<<endl;
       cin>>e;
       
       if (e==1)
       {
          cout<<"Welcome to Addition"<<endl;
          int g;
          int b;
          cout<<"Enter the two numbers you want to add "<<endl;
          cin>>g;
          cin>>b;
          int add;
          add = g + b;
          cin.get();
          cout<<g<<" plus "<<b<<" is "<<add<<endl;
          cin.get();
       }                       // you forgot the closing braces                 
       else if (e==2)   // use else-if instead of if, makes more sense
       { 
            // the rest of the code
    Fix similar mistakes for the rest of the code

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    You might want to edit your post to contain [ code] and [/ code] tags. It might make people more willing to help
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    42
    dont worry i found my mistakes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21