+ 2

please extend this coding into array or into more functions like trigonomentry and scientifc functions

please help me out :( #include<iostream> using namespace std; class Calculator { private: int no1,no2; char ch; public: int get_data() { cout<<"enter 1st No & 2nd No:"<<endl; cin>>no1>>no2; cout<<"enter a operation:"<<endl; cin>>ch; } int display_data() { if(ch=='+') cout<<"Sum is:"<<no1+no2; else if(ch=='-') cout<<"Diff is:"<<no1-no2; else if(ch=='*') cout<<"Multiplay is:"<<no1*no2; else if(ch=='/') cout<<"Quotient is:"<<no1/no2; else if(ch=='%') cout<<"Remainder is:"<<no1%no2; else cout<<"invalid operation:"; } }; int main() {Calculator C; C.get_data(); C.display_data(); return (0); }

5th Dec 2017, 12:55 PM
Dark soul
Dark soul - avatar
1 Antwort
+ 2
use the inbuilt mathematics functions to do that . Like acos(); sin(); tan(); log(); log_10(); pow(); sqrt(); etc ..
5th Dec 2017, 1:38 PM
RZK 022
RZK 022 - avatar