Quiz Week 3

In this quiz the user should input a number and if the input is a positive number the code should gave him the square root and cubic root of the number, but if the number is negative only the cubic rot shall be displayed.
e_1

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include
using namespace std;
#include
double x,s,c;
int main(){
cout <<“Type in a number”<<endl; cin >>x;
s=sqrt(x);
c=cbrt(x);
if(x>0){
cout <<“The square root is “<< s <<endl;
cout <<“The cubic root is “<< c <<endl;
}
else
cout <<“The cubic root is “<< c <<endl;
return 0;

Leave a comment