Thread: Menu options for a calculator

  1. #16
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    Quote Originally Posted by whiteflags View Post
    I think using a numerical value as a sentinel in a calculator like this would cause more difficult problems than the imaginary one you are solving with it.

    It's really too bad you're too good to bother with us mere mortals.
    You're a braindead idiot.
    I don't want to get involved in this thread because the OP doesn't seem to be able to do anything for himself. That's all. Go ahead and continue to hold his hand, moron.
    Explode the sunlight here, gentlemen, and you explode the entire universe. - Plan 9 from Outer Space

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,616
    Quote Originally Posted by algorism View Post
    You're a braindead idiot.
    I don't want to get involved in this thread because the OP doesn't seem to be able to do anything for himself. That's all. Go ahead and continue to hold his hand, moron.
    Whatever dude. Apparently you have a problem with me now. Whatever I did isn't worth it. I don't know what it is about this forum but everyone develops an unwarranted, ........ing smug, better-than-you attitude. No one asked you to post. You involved yourself. You're burned out and too stupid to take a break.

    ...............
    Last edited by whiteflags; 09-03-2017 at 06:33 PM.

  3. #18
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    Quote Originally Posted by whiteflags View Post
    Whatever dude. Apparently you have a problem with me now. Whatever I did isn't worth it. I don't know what it is about this forum but everyone develops an unwarranted, ........ing smug, better-than-you attitude. No one asked you to post. You involved yourself. You're burned out and too stupid to take a break.
    Whatever "dude". You were burned out the moment you arrived. Your code is always childish and overly-complicated.

    I notice that you aren't bothering to help the guy that you gave the bad advice to. You just dropped some crappy code on him and took off.

    If everyone becomes "smug" with you, then you are the common denominator.

    You keep posting total garbage, oblivious to how bad it is. You are pathetic.

    I'll be sure to point it out every time from now on, you talentless loser.
    Explode the sunlight here, gentlemen, and you explode the entire universe. - Plan 9 from Outer Space

  4. #19
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,616
    Quote Originally Posted by Xterik View Post
    ok i could do it but in the case 8 i have to do all the operations at once i tried to copy all the cases into the case 8 but doesn't work any ideas?
    When you copied and pasted, did you change entries[opcion - 1] to the correct string, or not? Because if you didn't, they would all be successively written to entries[7] and what you would see is the last operation performed. Every sprintf() for every operation should be different. You have to put the first number in entries[0], the second number in entries[1], addition answers in entries[2] and so on.

    Quote Originally Posted by algorism
    You were burned out the moment you arrived. Your code is always childish and overly-complicated.

    I notice that you aren't bothering to help the guy that you gave the bad advice to. You just dropped some crappy code on him and took off.
    Oh, the hypocrisy! You allude to "better" solutions, insult me, and then leave, and I write code and leave, but my actions were so much worse. You're acting like the adult here, aren't you?

    If you're going to have a problem with me, at least hold yourself to the same standard. Code you write would be broken too, if the user changes their requirements. I'm supposed to read minds to appease you, I suppose.
    Last edited by whiteflags; 09-03-2017 at 08:32 PM.

  5. #20
    Registered User
    Join Date
    Aug 2017
    Posts
    10
    yes i did it everything until case case 7 works perfectly now in case 8 i need to do all the operations at once
    Code:
        do    {
    
    
            printf("1-Ingrese el 1er numero (A=%s): \n", entries[0]);
            printf("2- Ingresar 2do operando (B=%s)\n", entries[1]);
            printf("3- Calcular la suma (%s)\n", entries[2]);
            printf("4- Calcular la resta (%s)\n", entries[3]);
            printf("5- Calcular la division (%s)\n", entries[4]);
            printf("6- Calcular la multiplicacion (%s)\n", entries[5]);
            printf("7- Calcular el factorial (%s)\n", entries[6]);
            printf("8- Calcular todas las operaciones (%s)\n", entries[7]);
            printf("9- Salir\n");
    
    
            scanf("%d",&opcion);
    
    
            switch(opcion)
            {
                case 1:
                    scanf("%f" , &num1);
                    sprintf(entries[opcion - 1], "%.3f", num1);
                    break;
                case 2:
                    scanf("%f" , &num2);
                    sprintf(entries[opcion - 1], "%.3f", num2);
                    break;
                case 3:
                    rta=suma( num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f+%.3f=%.3f", num1, num2,rta);
                    break;
                case 4:
                    rta=resta(num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f-%.3f=%.3f",num1, num2,rta);
                    break;
                case 5:
                    rta=division(num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f/%.3f=%.3f",num1, num2,rta);
                    break;
                case 6:
                    rta=multiplicacion(num1, num2);
                    sprintf(entries[opcion - 1], "%.3f*%.3f=%.3f",num1, num2,rta);
                    break;
                case 7:
                    rtaFact=factorial(num1);
                    sprintf(entries[opcion - 1], "%.3f=%d",num1 , rtaFact);
                    break;
                case 8:
                    rta=suma( num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f+%.3f=%.3f", num1, num2,rta);
    
    
                    rta=resta(num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f-%.3f=%.3f",num1, num2,rta);
    
    
                    rta=division(num1 , num2);
                    sprintf(entries[opcion - 1], "%.3f/%.3f=%.3f",num1, num2,rta);
    
    
                    rta=multiplicacion(num1, num2);
                    sprintf(entries[opcion - 1], "%.3f*%.3f=%.3f",num1, num2,rta);
    
    
                    rtaFact=factorial(num1);
                    sprintf(entries[opcion - 1], "%.3f=%d",num1 , rtaFact);
                    break;
                case 9:
                    seguir = 'n';
                    break;
    
    
            }
            system("cls");
            }while(seguir=='s');
        return 0;

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,616
    Okay, but in case 8, every string needs to be changed, not just string 7. Using opcion - 1 to access the entries is not good enough. Actually make the change
    Code:
    case 8:
        rta = suma(num1, num2);
       sprintf(entries[2], "%.3f+%.3f=%.3f", num1, num2,rta);
       
       rta = resta(num1, num2);
       sprintf(entries[3], "%.3f-%.3f=%.3f",num1, num2,rta);
    and so on. See the difference? Like I explained before, if you keep changing the same string, you'll only ever see the last operation.

  7. #22
    Registered User
    Join Date
    Aug 2017
    Posts
    10
    I see, this concept is new for me but i realized how this works, thanks for everything dude you help me a lot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming menu options
    By levitylek in forum C Programming
    Replies: 2
    Last Post: 11-17-2010, 06:04 PM
  2. Menu to select 1 of 2 options
    By gold2040 in forum C++ Programming
    Replies: 1
    Last Post: 01-22-2006, 03:50 PM
  3. Menu Options Verification?
    By wbeasl in forum C++ Programming
    Replies: 6
    Last Post: 09-13-2004, 09:28 PM

Tags for this Thread