27.9.14

OOP : Excercise-1 : Arithmetic Operators with operands as input

Write a program performing as calculator which allows all Arithmetic Operators with operands as input

1. Write a C program for performing as calculator which allows all Arithmetic Operators with operands from terminal. Few Input and Output sample are given below:
Recommended: Study Char/Char Array in C/C++           
       
            Sample Input: 1 + 4
            Sample Output: 5
            Sample Input: 8 % 2
            Sample Output: 0
            Sample Input: 6 / 2
            Sample Output: 3
            Sample Input: 5 / 2
            Sample Output: 2.5

30 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. /*Mujaffor Ali Sumon
    ID-201420170
    */


    #include
    #include

    using namespace std;

    int main()
    {
    int a,b,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>a;
    cout<<"Enter the second number: ";
    cin>>b;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = a+b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = a-b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = a*b;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = a/b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = a%b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete
  3. Md. Khairul Hasan
    201420529

    #include
    #include

    using namespace std;

    int main()
    {
    int x,y,result;
    string arithmatic;
    cout<<"enter the first number:";
    cin>>x;
    cout<<"enter the second number:";
    cin>>y;
    cout<<"use one of the four artimatic operations /, *, + or - :";
    cin>>arithmatic;
    if (arithmatic=="/" )
    result=x/y;
    cout<<"x / y ="<<result;
    if (arithmatic == "*")
    result=x*y;
    cout<<"x * y ="<<result;
    if (arithmatic == "+")
    result = x + y;
    cout<<"x+y ="<<result;
    if (arithmatic == "-")
    result = x-y;
    cout<<"x-y ="<<result;
    else
    cout<<"what is this? i said use arithmatic operations!";

    return 0;
    }

    ReplyDelete
  4. Md. Khairul Hasan
    201420529

    #include
    #include

    using namespace std;

    int main()
    {
    int x,y,result;
    string arithmatic;
    cout<<"enter the first number:";
    cin>>x;
    cout<<"enter the second number:";
    cin>>y;
    cout<<"use one of the four artimatic operations /, *, + or - :";
    cin>>arithmatic;
    if (arithmatic=="/" )
    result=x/y;
    cout<<"x / y ="<<result;
    if (arithmatic == "*")
    result=x*y;
    cout<<"x * y ="<<result;
    if (arithmatic == "+")
    result = x + y;
    cout<<"x+y ="<<result;
    if (arithmatic == "-")
    result = x-y;
    cout<<"x-y ="<<result;
    else
    cout<<"what is this? i said use arithmatic operations!";

    return 0;
    }

    ReplyDelete
  5. #include
    #include

    using namespace std;

    int main()
    {
    int a,b,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>a;
    cout<<"Enter the second number: ";
    cin>>b;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = a+b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = a-b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = a*b;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = a/b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = a%b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete
  6. yeasmin Akter
    ID:201420271
    #include
    #include

    using namespace std;

    int main()
    {
    int a,b,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>a;
    cout<<"Enter the second number: ";
    cin>>b;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = a+b;
    cout<<" The result of operation is: "<>a;
    cout<<"Enter the second number: ";
    cin>>b;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = a+b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = a-b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = a*b;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = a/b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = a%b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete
  7. MD:Rashed Prodhania
    ID : 201420763
    Batch : 46

    #include
    #include

    using namespace std;

    int main()
    {
    int a,b,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>a;
    cout<<"Enter the second number: ";
    cin>>b;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = a+b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = a-b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = a*b;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = a/b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = a%b;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete

  8. Md.Hasmot Hossen
    ID:201421066
    Batch:46th

    #include
    #include

    using namespace std;

    int main()
    {
    int b,c,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>b;
    cout<<"Enter the second number: ";
    cin>>c;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = b+c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = b-c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = b*c;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = b/c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = b%c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete

  9. Md.Hasmot Hossen
    ID:201421066
    Batch:46th

    #include
    #include

    using namespace std;

    int main()
    {
    int b,c,result;
    string op;
    cout<<" Calculator program"<<'\n'<<'\n';
    cout<<" ++++++++****+++++++"<<'\n'<<'\n';
    cout<<"Enter the first number: ";
    cin>>b;
    cout<<"Enter the second number: ";
    cin>>c;

    cout<<" Use Operator + for add :"<<'\n';
    cout<<" Use Operator - for Sub :"<<'\n';
    cout<<" Use Operator * for multi :"<<'\n';
    cout<<" Use Operator / for divided :"<<'\n';
    cout<<" Use Operator % for modulus :"<<'\n'<<'\n';

    cin>>op;
    if (op=="+" ){
    cout<<"================================"<<'\n';
    result = b+c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="-" ){
    cout<<"================================"<<'\n';
    result = b-c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="*" ){
    cout<<"================================"<<'\n';
    result = b*c;

    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }
    else if (op=="/" ){
    cout<<"================================"<<'\n';
    result = b/c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';
    }

    else if (op=="%" ){
    cout<<"================================"<<'\n';
    result = b%c;
    cout<<" The result of operation is: "<<result<<endl;
    cout<<"================================"<<'\n';

    }
    else
    {
    cout<<"======================================"<<'\n';
    cout<<"Syntex Error! Pls try again with correct"<<'\n';
    cout<<"========================================="<<'\n'<<'\n';
    }


    return 0;
    }

    ReplyDelete
  10. this is Arithmatic simple program

    ReplyDelete
  11. Md : jalis Mahmud
    ID : 201420762

    #include
    #include

    using namespace std;

    int main()
    {
    int x,y,result;
    string arithmatic;
    cout<<"enter the first number:";
    cin>>x;
    cout<<"enter the second number:";
    cin>>y;
    cout<<"use one of the four artimatic operations /, *, + or - :";
    cin>>arithmatic;
    if (arithmatic=="/" )
    result=x/y;
    cout<<"x / y ="<<result;
    if (arithmatic == "*")
    result=x*y;
    cout<<"x * y ="<<result;
    if (arithmatic == "+")
    result = x + y;
    cout<<"x+y ="<<result;
    if (arithmatic == "-")
    result = x-y;
    cout<<"x-y ="<<result;
    else
    cout<<"what is this? i said use arithmatic operations!";

    return 0;
    }

    ReplyDelete
  12. //Md. Imam Uddin
    //ID- 201420733


    //Calculator with char data input
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    int a,b,c=0;
    char ch;
    cin>>a>>ch>>b;
    switch(ch)
    {
    case '+':
    c=a+b;
    break;
    case '-':
    c=a-b;
    break;
    case '*':
    c=a*b;
    break;
    case '/':
    c=a/b;
    break;
    default:
    break;
    }
    cout<<c;
    }

    ReplyDelete
  13. //Md. Imam Uddin
    //Id- 201420733

    //calculator using sample class
    #include
    using namespace std;
    class Calculator
    {
    float a, b;
    public:
    float add(float, float);
    float subtract(float, float);
    float Multiplication(float, float);
    float Divided(float, float);

    };
    float Calculator::add(float a, float b)
    {
    return (a+b);
    }
    float Calculator::subtract(float a, float b)
    {
    return (a-b);
    }
    float Calculator::Multiplication(float a, float b)
    {
    return (a*b);
    }
    float Calculator::Divided(float a, float b)
    {
    return (a/b);
    }
    int main()
    {
    Calculator calc;
    float a,c;
    char bn;
    cout << "Enter math problem (eg. 1 + 2)" << endl;
    cin >>a>>bn>>c;
    switch(bn)
    {
    case '+':
    cout<<calc.add(a,c)<<endl;
    break;
    case '-':
    cout<<calc.subtract(a,c)<<endl;
    break;
    case '*':
    cout<<calc.Multiplication(a,c)<<endl;
    break;
    case '/':
    cout<<calc.Divided(a,c)<<endl;
    default:
    cout << "Please Enter correct math problem" << endl;
    }
    }

    ReplyDelete
  14. //Md. Imam Uddin
    //Id. 201420733

    #include
    using namespace std;

    class Imam
    {
    public:
    int a, b;

    void input()

    {
    cin>>a>>b;
    }

    void sum()

    {
    cout<<"\n\n";
    cout<<"Sum is ="<<a+b;
    }
    void mul()

    {
    cout<<"\n\n";
    cout<<"Multification is ="<<a*b;
    }

    void dev()

    {
    cout<<"\n\n";
    cout<<"Devied is ="<<a/b;
    }

    void sub()

    {
    cout<<"\n\n";
    cout<<"Substruction is ="<<a-b;
    }
    };

    int main()
    {
    Imam p;
    p.input();
    p.sum();
    p.mul();
    p.dev();
    p.sub();
    return 0;
    }

    ReplyDelete
  15. // Md Mijanur Rahman
    // ID: 201420765

    #include
    using namespace std;
    class square
    {
    public:
    int height;
    int width;
    int area();

    };
    int square::area()
    {
    return height*width;
    }

    int main()
    {

    square obj;
    obj.height = 10;
    obj.width = 5;
    cout<<"Area = "<<obj.area()<<endl;

    return 0;

    }

    ReplyDelete
  16. // Md Mijanur Rahman
    // ID: 201420765

    #include
    using namespace std;
    class square
    {
    public:
    int height;
    int width;
    int area();

    };
    int square::area()
    {
    return height*width;
    }

    int main()
    {

    square obj;
    obj.height = 10;
    obj.width = 5;
    cout<<"Area = "<<obj.area()<<endl;

    return 0;

    }

    ReplyDelete
  17. // Md Mijanur Rahman
    // ID: 201420765

    #include
    using namespace std;
    class square
    {
    public:
    int height;
    int width;
    int area();

    };
    int square::area()
    {
    return height*width;
    }

    int main()
    {

    square obj;
    obj.height = 10;
    obj.width = 5;
    cout<<"Area = "<<obj.area()<<endl;

    return 0;

    }

    ReplyDelete
  18. Name-Main Uddin
    ID-201421090
    Batch-46

    #include
    #include
    using namespace std;

    int main()
    {
    int Number1,Number2,result;
    string Operator;
    cout<<"Enter the first number: ";
    cin>>Number1;
    cout<<"Enter the second number: ";
    cin>>Number2;
    cout<<" Use Operator + = add :"<<'\n';
    cout<<" Use Operator - = Sub :"<<'\n';
    cout<<" Use Operator * = multi :"<<'\n';
    cout<<" Use Operator / = divided :"<<'\n';
    cout<<" Use Operator % = modulus :"<<'\n'<<'\n';
    cin>>Operator;

    if (Operator=="+" ){
    result = Number1+Number2;
    cout<<"FirstNumber + SecondNumber = "<<result<<endl;
    }

    else if (Operator=="-" ){
    result = Number1-Number2;
    cout<<" FirstNumber - SecondNumber = "<<result<<endl;
    }
    else if (Operator=="*" ){
    result = Number1*Number2;
    cout<<" FirstNumber * SecondNumber = "<<result<<endl;
    }
    else if (Operator=="/" ){
    result = Number1/Number2;
    cout<<" FirstNumber / SecondNumber = "<<result<<endl;
    }
    else if (Operator=="%" ){
    result = Number1%Number2;
    cout<<" FirstNumber % SecondNumber = "<<result<<endl;
    }
    else
    {
    cout<<"Syntex Error!"<<'\n';
    }
    return 0;
    }

    ReplyDelete
  19. Mohammad Ashraful Hasan sobuj
    CSE-46(Dip)
    ID=201420656



    #include
    using namespace std;
    main ()
    {
    int a,b,result;
    string arithmatic;
    cout<<"the first value:";
    cin>>a;
    cout<<"the second value:";
    cin>>b;
    cout<<"apply some artimatic operations /, *, + or - :";
    cin>>arithmatic;
    if (arithmatic="/" )
    result=a/b;
    cout<<"a / b ="<<result;
    if (arithmatic = "*")
    result=a*b;
    cout<<"a * b ="<<result;
    if (arithmatic = "+")
    result = a + b;
    cout<<"a+b ="<<result;
    if (arithmatic = "-")
    result = a-b;
    cout<<"a-b ="<<result;
    else
    cout<<"how is that? enter the value use arithmatic operations!";

    return 0;
    }

    ReplyDelete
  20. #include
    using namespace std;
    class calculator
    {
    float a,b;
    public:
    float add(float,float);
    float subtract(float,float);
    float multiply(float,float);
    float divide(float,float);
    };
    float calculator ::add(float a,float b)
    {
    return (a+b);
    }
    float calculator ::subtract (float a,float b)
    {
    return (a-b);
    }
    float calculator ::multiply (float a,float b)
    {
    return (a*b);
    }
    float calculator ::divide (float a,float b)
    {
    return (a/b);
    }
    int main()
    {
    calculator calc;
    float a,c;
    char b;
    cout<<"Enter Your Data As Like A+B"<>a>>b>>c;
    switch (b)
    {
    case'+':
    cout<<calc.add(a,c);
    break;
    case'-':
    cout<<calc.subtract(a,c);
    break;
    case'*':
    cout<<calc.multiply(a,c);
    break;
    case'/':
    cout<<calc.divide(a,c);
    break;
    default:
    cout<<"Please Enter Correct Data"<<endl;
    }

    }

    ReplyDelete
  21. sonia ferdusi
    45th
    #include
    using namespace std;
    class strange
    {
    int number;
    public:
    strange();
    ~strange();
    void view();
    };
    strange:: strange()
    {
    cout<<"Enter the value\n";
    cin>>number;
    }
    strange :: ~strange()
    {

    }
    void strange :: view()
    {
    int b ,temp ,rev=0;
    temp=number;
    while(temp!=0)
    {
    b=temp%10;
    rev=rev*10+b;
    temp /=10;
    }
    if(rev==number)
    cout<<"\nIt is a strange number\n\n";
    else
    cout<<"\nIt is not a strange number\n\n";

    }
    int main()
    {
    strange cp;

    cp.view();
    return 0;
    }

    ReplyDelete
  22. ID-201410530

    Write a C++ program using class to calculate square and cube of given number using inline function :

    ‪#‎include‬
    class power
    {
    public:
    inline int square(int n)
    {
    return n*n;
    }
    inline int cube(int n)
    {
    return n*n*n;
    }
    };
    void main()
    {
    int n,r;
    power p;
    clrscr();
    cout<<“\nEnter the Number: \n” ;
    cin>>n;
    r=p.square(n);
    cout<<“\nSquare of “<<n<<” = “<<r<<endl;
    r=p.cube(n);
    cout<<“\nCube of “<<n<<” = “<<r<<endl;
    getch();
    }

    ReplyDelete
  23. using c++
    #include
    using namespace std;

    class opr
    {
    public:
    int a, b;
    string c;
    opr(int i, string j, int k);
    int ret();
    ~opr();
    };

    opr::opr(int i, string j, int k)
    {
    a = i;
    c = j;
    b = k;
    }

    int opr::ret()
    {
    int sum = 0;
    if (c == "+"){
    sum = a + b;
    return sum;
    }
    else if (c == "-"){
    sum = a-b;
    return sum;
    }
    else if (c == "*"){
    sum = a * b;
    return sum;
    }
    else if (c == "/"){
    sum = a / b;
    return sum;
    }
    else if (c == "%"){
    sum = a % b;
    return sum;
    }
    else if (c == "pow"){
    sum = 1;
    for (int i = 0; i < b; i++)
    sum *= a;
    return sum;
    }
    }

    opr::~opr()
    {

    }
    int main()
    {
    int a, b;
    string c;
    cout << "Enter every single number or operator using space or enter.\n";
    cin >> a >> c >> b;

    opr obj(a, c, b);
    cout << obj.ret();

    return 0;
    }

    ReplyDelete
  24. ///Exercise 1
    ///Tisha
    ///201930034
    #include

    int main()
    {
    int x = 60;
    int y = 20;
    int z ;

    z = x + y;
    printf("Line 1 - sample output is %d\n", z );

    z = x - y;
    printf("Line 2 - sample output is %d\n", z );

    z = x * y;
    printf("Line 3 - sample output is %d\n", z );

    z = x / y;
    printf("Line 4 - sample output is %d\n", z );

    z = x % y;
    printf("Line 5 - sample output is %d\n", z );

    return 0;
    }

    ReplyDelete
  25. //Md.Nayem Hossain
    //Id:202010023
    //Batch 63


    #include
    using namespace std;

    class A
    {
    public :

    int addition (int a, int b)
    {
    int result = a+b;
    cout<<"Sample output 1 = "<<result<<endl;
    }
    int mod(int a,int b)
    {
    int result = a%b;
    cout<<"sample output 2 = "<<result<<endl;
    }
    float division (float a, float b)
    {
    float result = a/b;
    cout<<" sample output 3 ="<<result<<endl;

    }
    float division2(float x,float y)
    {
    float result = x/y;
    cout<<" sample output 4 ="<<result<<endl;

    }
    };
    int main()
    {
    A obj;
    obj.addition(1,4);
    obj.mod(8,2);
    obj.division (6,2);
    obj.division2 (5,2);
    }

    ReplyDelete
  26. // Murshida akater
    //id 202010463
    //Batch 63
    #include
    using namespace std;
    main()
    {
    int a=21;
    int b=10;
    int c;
    c=a+b;
    cout <<"line 1 value of c is:"<<c<<endl;
    c=a%b;
    cout<<"line 2 value of c is:"<<c<<endl;
    c=a*b;cout<<"line 3 value of c is :"<<c<<endl;
    c=a/b;cout <<"line 4 value of c is:"<<c<<endl;
    return 0;
    }

    ReplyDelete
  27. # include
    using namespace std;

    int main()
    {
    char op;
    float num1, num2;

    cout << "Enter operator either + or - or * or /: ";
    cin >> op;

    cout << "Enter two operands: ";
    cin >> num1 >> num2;

    switch(op)
    {
    case '+':
    cout << num1+num2;
    break;

    case '-':
    cout << num1-num2;
    break;

    case '*':
    cout << num1*num2;
    break;

    case '/':
    cout << num1/num2;
    break;

    default:
    cout << "Error! operator is not correct";
    break;
    }

    return 0;
    }

    ReplyDelete
  28. //jamil zilani
    //201930092

    # include
    using namespace std;

    int main()
    {
    char op;
    float num1, num2;

    cout << "Enter operator either + or - or * or /: ";
    cin >> op;

    cout << "Enter two operands: ";
    cin >> num1 >> num2;

    switch(op)
    {
    case '+':
    cout << num1+num2;
    break;

    case '-':
    cout << num1-num2;
    break;

    case '*':
    cout << num1*num2;
    break;

    case '/':
    cout << num1/num2;
    break;

    default:
    // If the operator is other than +, -, * or /, error message is shown
    cout << "Error! operator is not correct";
    break;
    }

    return 0;
    }

    ReplyDelete
  29. //jamil zilani
    //201930092

    # include
    using namespace std;

    int main()
    {
    char op;
    float num1, num2;

    cout << "Enter operator either + or - or * or /: ";
    cin >> op;

    cout << "Enter two operands: ";
    cin >> num1 >> num2;

    switch(op)
    {
    case '+':
    cout << num1+num2;
    break;

    case '-':
    cout << num1-num2;
    break;

    case '*':
    cout << num1*num2;
    break;

    case '/':
    cout << num1/num2;
    break;

    default:

    cout << "Error! operator is not correct";
    break;
    }

    return 0;
    }

    ReplyDelete
  30. https://docs.google.com/document/d/1AHtuQljwsNZ_VxWkjCGCvhfJKFKjBwBqLrAtXjbA9uY/edit?usp=sharing

    ReplyDelete

Comment Here