Results 1 to 5 of 5

Thread: calculator in c++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    hussain king is offline Senior Member+
    Last Online
    4th April 2019 @ 06:44 AM
    Join Date
    14 Feb 2018
    Gender
    Male
    Posts
    100
    Threads
    42
    Credits
    -1,186
    Thanked
    2

    Thumbs up calculator in c++

    /* prepared by : HILAL AHMAD HUSSAIN (STUDENT: SOFTWERE ENGINEERING)
    */
    #include<iostream>
    #include<conio.h>
    int add(int a,int b);
    int sub(int a,int b);
    int mul(int a,int b);
    int div(int a,int b);
    using namespace std;
    int main()
    {
    int m,n;
    xy:
    cout<<endl;
    cout<<"___________________________________________ __________________________"<<endl;
    cout<<"please enter your first number=";
    cin>>m;
    cout<<endl;
    cout<<"please enter your 2nd number=";
    cin>>n;
    cout<<endl;
    cout<<"1: for addition"<<endl;
    cout<<"2: for substriction"<<endl;
    cout<<"3: for multifaction "<<endl;
    cout<<"4: for division"<<endl;
    cout<<"please enter your option do you want to operation----";
    char op;
    cin>>op;
    switch(op)
    {
    if(op=='1')
    {
    case '1':
    add( m, n);
    break;
    }
    else{
    cout<<"dear your enter invilid option please corrent option enter try again"<<endl;
    }
    if(op=='2')
    {
    case '2':
    sub( m, n);
    break;
    }
    else{
    cout<<"dear your enter invilid option please corrent option enter try again"<<endl;
    }
    if(op=='3')
    {
    case '3':
    mul(m, n);
    break;
    }
    else{
    cout<<"dear your enter invilid option please corrent option enter try again"<<endl;
    }
    if(op=='4')
    {
    case'4':
    div( m, n);

    }else{
    cout<<"dear your enter invilid option please corrent option enter try again"<<endl;

    }
    default:
    cout<<"invilid option----";
    }
    goto xy;
    }
    int add(int a,int b)
    {
    cout<<"--------------------------------"<<endl;
    cout<<"the addition of a and b ="<<a+b<<endl;
    cout<<"--------------------------------"<<endl;
    cout<<endl;

    }
    int mul(int a, int b)
    {
    cout<<"--------------------------------"<<endl;
    cout<<"the multifaction of a and b="<<a*b<<endl;
    cout<<"--------------------------------"<<endl;
    cout<<endl;

    }
    int sub(int a,int b)
    {
    cout<<"--------------------------------"<<endl;
    cout<<"the substraction of a and b="<<a-b<<endl;
    cout<<"--------------------------------"<<endl;
    cout<<endl;
    }
    int div(int a,int b)
    {
    if(b==0)
    {
    cout<<"--------------------------------"<<endl;
    cout<<"a is not divide by zero"<<endl;
    cout<<"--------------------------------"<<endl;
    }
    else
    {
    cout<<"--------------------------------"<<endl;
    cout<<"the division of a and b="<<a/b<<endl;
    }

    cout<<endl;

    }




    dear no error see result again
    Attached Images Attached Images  
    Last edited by hussain king; 30th March 2018 at 08:12 PM.

Similar Threads

  1. AGE CALCULATOR
    By abid436 in forum Excel Course From Zaara
    Replies: 18
    Last Post: 10th March 2021, 11:34 AM
  2. All in One Calculator
    By ItHero in forum Software Reviews
    Replies: 50
    Last Post: 21st May 2016, 11:13 AM
  3. C++ (OOP) - ITD Calculator 8.5
    By bais in forum C++
    Replies: 11
    Last Post: 25th November 2015, 11:25 PM
  4. WEb Calculator
    By shaaf in forum English IT Zone
    Replies: 6
    Last Post: 15th December 2010, 07:47 AM
  5. My VB Calculator!
    By SufyanGujar in forum English IT Zone
    Replies: 5
    Last Post: 30th November 2009, 08:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •