TheMighty TheMighty - 1 year ago 72
C++ Question

The program does'nt give output

I am using the following code to print out the code, and i doesn't show the correct area of the circle. it shows -215487854145 as the area of the circle..

please help me
the code below code:

kindly help me as i am new to this language, i think i did everything right please

#include <iostream>

using namespace std;

int main()
int a, r;
a = 3.14 * r * r ;

cout << "enter Radius";

cin >> r;

cout << "area of circle is";
cout << a;

return 0;

Answer Source

You used r in a calculation before you ever read in the value. Move it after you read it in.

cin >> r;
a = 3.14 * r * r ;