function is x/y+z means (x/y)+z
if you dont write to Z anything
program says "ERROR: Operator-operand imbalance."
program is that as it is above

and my code is

#include <iostream>
using namespace std;
class Calculator
{
      int x,y,z;
      public:
             void arith_ex(int,int,int);
      };
      
      void Calculator::arith_ex(int x,int y,int z)
      {
               cout<<"X="<<endl;
               cin>>x;
               cout<<"Y="<<endl;
               cin>>y;
               cout<<"Z="<<endl;
               cin>>z;
               if(z==' ')
               {cout<<"ERROR: Operator-operand imbalance."<<endl;
               }
           cout<<"Sonuc="<<x/y+z<<endl;
           }
    
        
           
           int main()
           {
               Calculator hesap;
               
               hesap.arith_ex(int x,int y ,int z); //expected primary expression before 'int'//
              
               return 0;
               }


ERRORS--> error C2144: syntax error : missing ')' before type 'int'
error C2660: 'arith_ex' : function does not take 0 parameters
error C2059: syntax error : ')'

You don't specify the types when you call the function. hesap.arith_ex(x,y , z); But you also have no x,y,z to pass to the function either.

You have declared variables x,y,z as members of the class and also as parameter values of the function arith_ex do something like this

void Calculator::arith_ex(int x,int y,int z)
      {
               if(z==' ')
               {cout<<"ERROR: Operator-operand imbalance."<<endl;
               }
           cout<<"Sonuc="<<x/y+z<<endl;
           }

and call the function as

hesap.arith_ex(5,4,3); //or any other values entered by the user

alternatively you can define the function without any arguments like

void Calculator::arith_ex()
{
//rest of the code here
}

in this line hesap.arith_ex(int x,int y ,int z); x,y,z are undefined. Declare them earlier in the code and assign them some values.

but i want to take numbers from user
how can i ?

but i want to take numbers from user
how can i ?

You already correctly take all the input from the user by using cin, e.g. the following works cin>>x; But you cannot call a function like this: hesap.arith_ex(int x,int y ,int z); The above line actually generates all of the three errors you get.

You are not allowed to specify the types of the arguments you pass to a function when you make the function call. Instead you need to do it like:

// declare the variables you need to pass to the function
int x = 0;
int y = 0;
int z = 0;

// here you might also get the values from the user, using cin 

hesap.arith_ex(x, y, z); // now make the function call with the arguments

thanky you so much
it works now

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.