Odd math result
Simple routine to calculate the area of a circle:
#include <iostream> useing namespace std; int main() { float radius; float area(3.14159 * radius * radius);' cout << "Enter the radius "; cin >> radius; cout << "Area is: " << area << endl; } Now, a radius of 5 should yield a result of 78.xxxx (irr). But this routine yields 12.xxx. Anyone have any ideas as to why this routine doesn't work? :( |
is this your complete code? next time please copy and paste to avoid typo.
you need to do the calculation of area after you get the radius with cin. Code:
#include <iostream> |
You are quite correct, csfalcon. That worked. :rolleyes:
Thank you very much! :) |
All times are GMT -5. The time now is 05:07 PM. |