Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This imports stuff from "iostream" which handles input and output.
- In this case = input being the radius and output being the messages and the answer*/
- #include <iostream>
- using namespace std;
- /*This defines stuff I use later on to make life easier, instead of typing 3.14159 every time I use it I can just type "PI"
- NEWLINE is basically ENTER, and PI is, well, PI*/
- #define PI 3.14159
- #define NEWLINE '\n'
- /*This is the "main" function, when I compile it, it looks for "main" first, so I put the stuff inside it*/
- int main ()
- {
- /*This declares the integers I am going to use later, "double" is a number that can also have a decimal point.
- if I just used "int" it would only accept whole numbers, so I used "double" so I could get a more accurate answer.*/
- double r;
- double circle;
- double h;
- /*"cout" means that it is going to print something on the screen, with the words in quotation marks being what gets printed
- First up it prints out what the program does*/
- cout << "Calculate the Circumference";
- /*Then it puts in new lines, or enters*/
- cout << NEWLINE;
- cout << NEWLINE;
- /*Then it asks you to enter a number*/
- cout << "Enter radius: ";
- /*It takes the number you just entered and stores it as the "double" of "r" which we declared above all this*/
- cin >> r;
- /*Then it does the calculation to get the answer*/
- circle = 2 * PI * r;
- /*It then takes the answer and prints it on the screen*/
- cout << "Circumference = ";
- cout << circle;
- cout << NEWLINE;
- /*This is to make it close, I forgot the code to make it close after you hit enter so I made this instead
- it takes input, stores it as "h" */
- cout << "To close type anything and press ENTER \n";
- cin >> h;
- /*Then if "h" equals anything, it "returns 0" which means "Close program"*/
- if(h){
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement