C++ program errors, cant fix, help?

#include <stdio.h>

int main()
{
double PI = 3.14; //variable declaration
double radius;
double area;

printf("Enter radius: "); //prompt

area = PI * radius * radius; //assignment statement to compute area

printf("the radius is: %d\n" &radius); //output radius value

printf("the area is: %d\n", &area); //output area value

Return 0;
}
Last edited on
C++ program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

int main()
{
    const double PI = 3.14159265 ;

    double radius;
    std::cout << "Enter radius: " ; //prompt
    std::cin >> radius ; // read in the radius
    // for now, we will assume that the user entered a positive value

    const double area = PI * radius * radius; // calculate area

    std::cout << "the radius is: " << radius << '\n' //output radius value
              << "the area is: " << area << '\n' ; //output area value
}
Topic archived. No new replies allowed.