Advertisement
bwukki

Untitled

Jan 20th, 2018
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.95 KB | None | 0 0
  1. //2.16
  2. int main(){
  3.     double numOne{0};
  4.     double numTwo{0};
  5.     cout << "Please enter two numbers: " << endl;
  6.     cin >> numOne >> numTwo;
  7.     cout << "The sum is: " << numOne + numTwo << endl;
  8.     cout << "The difference is: " << numOne - numTwo << endl;
  9.     cout << "The product is: " << numOne * numTwo << endl;
  10.     cout << "The quotient is: " << numOne / numTwo << endl;
  11.     return 0;
  12. }
  13.  
  14.  
  15. //2.17
  16. int main(){
  17.     cout << "1 2 3 4" << endl;
  18.  
  19.     cout << "1 " << "2 " << "3 " << "4" << endl;
  20.  
  21.  
  22.     cout << "1 ";
  23.     cout << "2 ";
  24.     cout << "3 ";
  25.     cout << "4" << endl;
  26.     return 0;
  27. }
  28.  
  29. //2.18
  30. int main()
  31. {
  32.     double numOne{0};
  33.     double numTwo{0};
  34.     cout << "Please enter two numbers" << endl;
  35.     cin >> numOne >> numTwo;
  36.     if ( numOne > numTwo ){
  37.         cout << numOne << " is larger." << endl;
  38.     }
  39.     if ( numTwo > numOne) {
  40.         cout << numTwo << " is larger." << endl;
  41.     }
  42.     if (numOne == numTwo) {
  43.         cout << numOne << " and " << numTwo << " are equal" << endl;
  44.     }
  45. return 0;
  46. }
  47.  
  48. //2.19
  49. int main(){
  50.     double numOne{0};
  51.     double numTwo{0};
  52.     double numThree{0};
  53.     double numLargest{0};
  54.     double numSmallest{0};
  55.  
  56.     cout << "Please enter three numbers" << endl;
  57.     cin >> numOne >> numTwo >> numThree;
  58.  
  59.     if (numOne > numTwo) {
  60.         numLargest = numOne;
  61.     }
  62.     else {
  63.         numLargest = numTwo;
  64.     }
  65.     if (numLargest < numThree) {
  66.         numLargest = numThree;
  67.     }
  68.     if (numOne < numTwo) {
  69.         numSmallest = numOne;
  70.     }
  71.     else {
  72.         numSmallest = numTwo;
  73.     }
  74.     if (numSmallest > numThree) {
  75.         numSmallest = numThree;
  76.     }
  77.  
  78.     cout << "Sum is " << numOne + numTwo + numThree << endl;
  79.     cout << "Average is " << (numOne + numTwo + numThree)/ 3 << endl;
  80.     cout << "Product is " << numOne * numTwo * numThree << endl;
  81.     cout << "Smallest is " << numSmallest << endl;
  82.     cout << "Largest is " << numLargest << endl;
  83.     return 0;
  84. }
  85.  
  86. //2.20
  87. int main(){
  88.     double pi{3.14159};
  89.     int r{0};
  90.     cout << "Please type a radius: " << endl;
  91.     cin >> r;
  92.     cout << "Diameter: " << 2*r << "\n" << "Circumference: " << 2*pi*r << "\n" << "Surface Area: " << pi*r*r << endl;
  93.     return 0;
  94. }
  95.  
  96. //2.28
  97. int main(){
  98.     int r{0};
  99.     cout << "Please type a 5 digit integer" << endl;
  100.     cin >> r;
  101.     cout << (r / 10000) << "   " << (r / 1000) % 10 << "   " << (r / 100) % 10 << "   " << (r / 10) % 10 << "   " << (r) % 10 << "   " << endl;
  102.     return 0;
  103. }
  104.  
  105. //2.30
  106. int main(){
  107.     int weight{0};
  108.     int height{0};
  109.     cout << "Please type your weight in pounds: " << endl;
  110.     cin >> weight;
  111.     cout << "Please type your height in inches: " << endl;
  112.     cin >> height;
  113.     cout << "Your BMI is: " << (weight * 703)/(height*height) << endl;
  114.     cout << "BMI VALUES";
  115.     cout << "Underweight: less than 18.5 \nNormal: between 18.5 and 24.9 \nOverweight: between 25 and 29.9 \nObese: 30 or greater" << endl;
  116.     return 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement