Thread: simple calculator

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    5

    simple calculator

    I made some simple basix calculator in dev c++ like c program and I would like to change it a bit. Does anyone can help me make that this program will calculate like this:
    you write 5*5 and it will write 25 and it will set in you new line and you will be able to write numbers again and it will calculate it again.
    Now program calculate it and it just close after that.
    It look like this:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main(int argc, char *argv[])
    {float a,b,r;
    char op;
    scanf("%f%c%f", &a, &op, &b);
    switch(op)
    {case '+':r=a+b;
    printf("%f", r);
    break;
    case '-':r=a-b; 
    printf("%f", r); 
    break;
    case '*':r=a*b; 
    printf("%f", r); 
    break;
    case '/':r=a/b; 
    printf("%f", r); 
    break;
    default: printf ("Nekaj ne delas prav"); }
    
       system("PAUSE"); 
      return 0;
    }

    Any idea what do I have to change to don't stop after 1st calculation ?
    and I just figured out that it calculate only 5 numbers max so if I write 5*5*5 it will write me resault: 25 ... any idea on that too?
    I'm new in programming so please don't flame me.




    Symcy
    Last edited by symcy; 02-05-2011 at 11:26 AM. Reason: Wrong code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Socialising Chat Bots
    By bengreenwood in forum C++ Programming
    Replies: 10
    Last Post: 11-28-2007, 08:42 AM
  2. simple calculator
    By HunterCS in forum C++ Programming
    Replies: 10
    Last Post: 07-18-2007, 06:51 AM
  3. GUI Calculator - Critique
    By The Brain in forum Windows Programming
    Replies: 1
    Last Post: 02-25-2006, 04:39 AM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. A Simple Calculator Program Not Working
    By oobootsy1 in forum C++ Programming
    Replies: 9
    Last Post: 01-09-2004, 09:34 PM

Tags for this Thread