By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Forums - General Discussion - Borland C++ Excersise help.

Edit: My first problem is solved, I just need 1 more thing, I need to solve a cube and fourth root, but I don't know how

#include <iostream.h>
#include <conio.h>
#include <math.h>

float a,s,c,f;
void main()
{
    cout<<"Add a number";
   cin>>a;
   s= sqrt(a);
   c= ???
   f= ???
   cout<<"The square root is: "<<s<<endl;
   cout<<"The cubic root is: "<<c<<endl;
   cout<<"The fourth root is: "<<f<<endl;
   getch();
}



Around the Network

#include <iostream.h>

#include <conio.h>

void main()

{

    float a,b,r;

    cout<<"add first number: ";
    cin>>a;
    cout<<"add second number: ";
    cin>>b;
    r=a b;
    cout<<"nEl resultado de:  "<<a<<" "<<b<<" = " <<r;
    getch();
}

That should work hopefully, a lil tired. 



Jazzy is right, plus :

 

There is no semicolon after void main() also, you should use curly brackets 

void main()

{

//code

}



Yeah.

float a,b,r;

and

void main()
{

}

PS. {} not ().



Creo que con esos cambios queda corregido el código. Si le aparece algún error adicional, solo coloquelo en el foro y le ayudamos a corregirlo.

I think with those changes the code is fixed. If you get an aditional error, just put it in the forum and we will help you fix it.



Around the Network

Thanks, my mistakes where putting a ";" after "main" and not using {}

Thanks



I know it's already fixed and you got it working, but add

cout<<"el resultado de "<<a<<" "<<b<<" = " <<r<< endl;

to get a line break, else you'll mess up the prompt if you run it in command line....plus it'll look nicer and your teacher will like you more




Well, that was helpful, I need another thing (see op to see what else I need)

@Zexen: Thanks, that was of much help!!



I'm sure someone will correct me, but I think you can use POW.

ie 

cout << "x to 3rd power is: " << pow (x, 3) <<  endl;



JazzyJeez said:

I'm sure someone will correct me, but I think you can use POW.

ie 

cout << "x to 3rd power is: " << pow (x, 3) <<  endl;


actually, it's the complete oposite process