Very basic Calculator program in C++

in #programming7 years ago

 Program

<p dir="auto">A program is set of instruction given by user to computer to perform a specific task.computer program, in depth intend or else process in lieu of solving a riddle by means of a computer; supplementary specifically, an unambiguous, well thought-out string of computational advice indispensable near attain such a solution.   <h1>Program Body: <pre><code>#include< math.h>am  > <pre><code>#include< math.h > <pre><code>using namespace std; <pre><code>class calculator{ <pre><code>private: <pre><code>double first,scnd,result; <pre><code>char op; <pre><code>public: <pre><code>void cal(){ <pre><code>cout<<"Enter your first value "<<endl; <pre><code>cin>>first; <pre><code>cout<<"put any basic operator "<<endl; <pre><code>cin>>op; <pre><code>cout<<"Enter your second value"<<endl; <pre><code>cin>>scnd; <pre><code>if(op=='+'){ <pre><code>        result=first+scnd; <pre><code>    cout<<"your result is "<<result<<endl; <pre><code>} <pre><code>else if(op=='-') <pre><code>    { <pre><code>result=first-scnd; <pre><code>cout<<"your result is "<<result<<endl; <pre><code>} <pre><code>else if(op=='*') <pre><code>{ <pre><code>result=first*scnd; <pre><code>cout<<"Your result is "<<result<<endl; <pre><code>} <pre><code>else if(op=='/') <pre><code>{ <pre><code>result=first/scnd; <pre><code>cout<<"your result is "<<result<<endl; <pre><code>} <pre><code>} <pre><code>}; <pre><code>int main(){ <pre><code>calculator object; <pre><code>object.cal(); <pre><code>} <p dir="auto">  <h1>Written in C++ <p dir="auto"><img src="https://images.hive.blog/768x0/https://howtolearn.me/wp-content/uploads/2014/06/c-++-logo.jpg" srcset="https://images.hive.blog/768x0/https://howtolearn.me/wp-content/uploads/2014/06/c-++-logo.jpg 1x, https://images.hive.blog/1536x0/https://howtolearn.me/wp-content/uploads/2014/06/c-++-logo.jpg 2x" /> <p dir="auto"><a href="https://howtolearn.me/wp-content/uploads/2014/06/c-++-logo.jpg" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Source <h1>Made in Visual C++ IDE <p dir="auto"><img src="https://images.hive.blog/768x0/https://steemitimages.com/0x0/http://domoticx.com/wp-content/uploads/Microsoft-Visual-C-logo.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/0x0/http://domoticx.com/wp-content/uploads/Microsoft-Visual-C-logo.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/0x0/http://domoticx.com/wp-content/uploads/Microsoft-Visual-C-logo.png 2x" /> <p dir="auto"><a href="https://steemitimages.com/0x0/http://domoticx.com/wp-content/uploads/Microsoft-Visual-C-logo.png" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Source <h3><em> I hope it was helpful and you learned something from it, Thanks