The assignment is: Write a program in C++ that inputs a value into a variable n and outputs the cube (n*n*n). Make sure the user of your program knows when to enter the integer and knows the result is the cube of the integer n. After emailing my code to my professor his only response to my email was..."There were errors". I have ran my program and I don't understand where the error is! Is there something I'm missing?
// A program that cubes your numbers!
double n, nCubed;
cout << "Please enter a number and press enter" << endl;
cin >> n;
nCubed = (n*n*n);
cout << "Your number cubed is:" << nCubed << " " <<endl;
well i would first make n and nCubed an int. i dont see any errors, but instead of another variable i would do cout<<"..."<< n*n*n <<"...". also why is there a space after ncubed? its useless. other than that, i dont see anything wrong with it. can you post the whole assignment?
"Write a program in C++ that inputs a value into a variable n and outputs the cube (n*n*n). Make sure the user of your program knows when to enter the integer and knows the result is the cube of the integer n."
^^That is actually the entire assignment...but perhaps its because I declared a "double" instead of "int"....I'll modify that and hopefully it would help resolve the issue and get rid of the useless space lol. Thank you so much for the feedback! Greatly appreciated!!