Reads in the radius of a circle as an integer and prints the circle's diameter, circumference and area. - C++ Language Basics

C++ examples for Language Basics:Console

Description

Reads in the radius of a circle as an integer and prints the circle's diameter, circumference and area.

Demo Code

#include <iostream>

const double PI = 3.14159;

int main(int argc, const char *argv[]) {
    int radius;//  w w w .  j  a v  a2  s. c  o  m

    std::cout << "Enter an integer value circle radius: ";
    std::cin >> radius;

    std::cout << "Diameter: " << 2 * radius << std::endl;
    std::cout << "Circumference: " << PI * (2 * radius) << std::endl;
    std::cout << "Area: " << PI * (radius * radius) << std::endl;

    return 0;
}

Result


Related Tutorials