Calculator should display the accumulated value after each operation

//FILE: PROGRAM3.CPP
//AUTHOR : AM NGUYEN 
//COURSE NAME : CS210
//DATE : 
// DESCRIPTION : A SIMPLE CALCULATOR

# include <iostream> 
using namespace std;
void instruction();
int calculator (char);
void divide_by_zero ();
float do_next_op (char, float, float);

void main()
{ 
     //input
     char input;
     float accum,num;
     
      // instructions ();
      accum = 0 
      //get input 
      cout<< " : " ;
      cin >> input;
      
      while (input != 'Q' && input != 'q' && input != '=')
      { 
            cin >> num;
      // Do op
      accum = do_next_op (input, num, accum);
      //display result
      cout << " Result so far : " << accum << endl;
      
      // get next operation 
      cout << "teo mun "<< endl      ;
      } // end not quit
      
      cout << "Final result : " 
     system ("pause") ;  
      return 0 ;
      }
      //instruct user 
      void instruction() 
      cout <<" This program models a simple calculator which can add, subtract,multiply,divide, power" << endl;
      cout << " the calculator accumulate value after each operation " << endl;
      cout << " press Q to quit the program " << endl;
      cout << " Have fun with my program " << endl<< endl;
      
      // function do_next_op ()
      //perform next operation
      // input : operator, operand,and accumulated
      //output : new result
      float do_next_op (char op, float num, float total)
      {
            switch (op)
            {
                   case ' + ' :
                        total += num
                        break;
                   case ' - ' :
                        total -= num
                        break;
                   case ' * ' :
                        total *= num
                        break;
                   case ' / ' : 
                        total /= num 
                   case ' ^ ' :
                        total ^= num
                        break ;
                        default :
                                cout << " syntax error"
                                << endl;
                                
                                }

it cause the error, please help me to fix those error, more over, I am not sure about the while, for ,do while statement, please explain more for me. thank you

the error is main must return int

I declared the void for main already
yes ,this is most likely my complete code

Is this your complete code ? Because I don't see any ending braces for your do_next_op function. Also what errors do you get, elaborate !!

yep, this is, I just edit mycode

1. Please use "int main()". You are returning 0 at the end of main(), yet you declare that main() return void.

2. You lack a closing brace "}" and a return statement for do_next_op().

There are a host of compile errors in your code. accum = 0 .. missing semi-colon at the end.

Go through your compile errors and try to fix as many of those as you can, otherwise how are you going to understand what went wrong ?

Go through your compile errors and try to fix as many of those as you can, otherwise how are you going to understand what went wrong ?

he might expects us to do so.......

well I hope not :) .. one should really put in some effort !

" This program models a simple calculator which can add, subtract,multiply,divide, power"

I don't see any power operation in the program. If you meant to the ^ operator, it doesn't do power (at least in c++). It's an operator which works on bits. For power you need to implement a function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.