Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. /*This imports stuff from "iostream" which handles input and output.
  2. In this case = input being the radius and output being the messages and the answer*/
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. /*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"
  7. NEWLINE is basically ENTER, and PI is, well, PI*/
  8. #define PI 3.14159
  9. #define NEWLINE '\n'
  10.  
  11. /*This is the "main" function, when I compile it, it looks for "main" first, so I put the stuff inside it*/
  12. int main ()
  13. {
  14.  
  15.     /*This declares the integers I am going to use later, "double" is a number that can also have a decimal point.
  16.     if I just used "int" it would only accept whole numbers, so I used "double" so I could get a more accurate answer.*/
  17.     double r;
  18.     double circle;
  19.     double h;
  20.  
  21.     /*"cout" means that it is going to print something on the screen, with the words in quotation marks being what gets printed
  22.     First up it prints out what the program does*/
  23.     cout << "Calculate the Circumference";
  24.     /*Then it puts in new lines, or enters*/
  25.     cout << NEWLINE;
  26.     cout << NEWLINE;
  27.     /*Then it asks you to enter a number*/
  28.     cout << "Enter radius: ";
  29.     /*It takes the number you just entered and stores it as the "double" of "r" which we declared above all this*/
  30.     cin >> r;
  31.     /*Then it does the calculation to get the answer*/
  32.     circle = 2 * PI * r;
  33.     /*It then takes the answer and prints it on the screen*/
  34.     cout << "Circumference = ";
  35.     cout << circle;
  36.     cout << NEWLINE;
  37.  
  38.     /*This is to make it close, I forgot the code to make it close after you hit enter so I made this instead
  39.     it takes input, stores it as "h" */
  40.    
  41.     cout << "To close type anything and press ENTER \n";
  42.     cin >> h;
  43.  
  44.     /*Then if "h" equals anything, it "returns 0" which means "Close program"*/
  45.     if(h){
  46.         return 0;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement