#include <iostream>
#include <iomanip>
using namespace std;
class Derivate
{
public:
showDerivate();
void showFunc();
};
int main()
{ int nr;
Derivate drv;
drv.showFunc();
drv.showDerivate();
std::cin.get();
return 0;
}
void Derivate::showFunc()
{
cout<<"Nr"<<setw(20)<<"Function"<<endl;
cout<<"1"<<setw(20)<<"x"<<endl;
cout<<"2"<<setw(20)<<"cx"<<endl;
cout<<"3"<<setw(20)<<"xpowc"<<endl;
cout<<"4"<<setw(20)<<"1/x"<<endl;
cout<<"5"<<setw(21)<<"1/xpowc"<<endl;
cout<<"6"<<setw(20)<<"sqrt x"<<endl;
cout<<"7"<<setw(21)<<"epowx"<<endl;
cout<<"8"<<setw(20)<<"lnx"<<endl;
cout<<"9"<<setw(20)<<"sinx"<<endl;
cout<<"10"<<setw(20)<<"cosx"<<endl;
}
int Derivate::showDerivate()
{cout<<"give the respective number ofe the function you want to derivate"<<endl;
cin>>nr;
if (nr !=-1){
cout<<"function"<<setw(21)<<"derivate"<<endl;
switch (nr)
{ case 1: cout<<"x"<<setw(21)<<"1"<<endl;
break;
case 2: cout<<"cx"<<setw(21)<<"c"<<endl;
break;
case 3: cout<<"xpowc"<<setw(21)<<"c*xpow c-1"<<endl;
break;
case 4: cout<<"1/x"<<setw(21)<<"-1/xpow2"<<endl;
break;
case 5: cout<<"1/xpowc"<<setw(21)<<"-c/xpow(c+1)"<<endl;
break;
case 6: cout<<"sqrt x"<<setw(21)<<"1/2sqrtx"<<endl;
break;
case 7: cout<<"epowx"<<setw(21)<<"epowx"<<endl;
break;
case 8: cout<<"lnx"<<setw(21)<<"1/x"<<endl;
break;
case 9: cout<<"sinx"<<setw(21)<<"cosx"<<endl;
break;
case 10: cout<<"cosx"<<setw(21)<<"-sinx"<<endl;
break;}
}
else
{return int showDerivate();}
}
pucivogel 0 Newbie Poster
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.