Need help with a problem

This is a discussion on Need help with a problem within the C++ Programming forums, part of the General Programming Boards category; The progrem itself is working fine ,but i want to calculed the square and cubic number without having to manually ...

Need help with a problem

The progrem itself is working fine ,but i want to calculed the square and cubic number without having to manually input the square and cibic variable(a ,c ).I tried a few ideas but every time the compuler showed and error and this is the only way I made the program work.

A tip from me would be to clearly state why you are not happy with your code.

A suggestion for your code would be to have an outer if that asks the user if he wants to input values.This will get you into the default values concept that you will probably meet in the future with C++.
Example

Comment : Yes , again the user has to input at least once, but you will save him time if he wants no to input.Instead of three inputs he gives one.Notice that with more variables, if he didn't want to input, then again he had to input only once. This can be very helpful in programs with trees or matrices that ask the user if he wants to input something.If not , default values are preserved.

Question : What will happen if we do not give default values to our variables and let the user decide if he wants to input or not.If he wants, then everything ok, if not, what are the values of our variables?
In this case they will be automatically initiated to zero.But it is a good style of coding to clearly state what the values of your variables are.It also helps readability