Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //2.16
- int main(){
- double numOne{0};
- double numTwo{0};
- cout << "Please enter two numbers: " << endl;
- cin >> numOne >> numTwo;
- cout << "The sum is: " << numOne + numTwo << endl;
- cout << "The difference is: " << numOne - numTwo << endl;
- cout << "The product is: " << numOne * numTwo << endl;
- cout << "The quotient is: " << numOne / numTwo << endl;
- return 0;
- }
- //2.17
- int main(){
- cout << "1 2 3 4" << endl;
- cout << "1 " << "2 " << "3 " << "4" << endl;
- cout << "1 ";
- cout << "2 ";
- cout << "3 ";
- cout << "4" << endl;
- return 0;
- }
- //2.18
- int main()
- {
- double numOne{0};
- double numTwo{0};
- cout << "Please enter two numbers" << endl;
- cin >> numOne >> numTwo;
- if ( numOne > numTwo ){
- cout << numOne << " is larger." << endl;
- }
- if ( numTwo > numOne) {
- cout << numTwo << " is larger." << endl;
- }
- if (numOne == numTwo) {
- cout << numOne << " and " << numTwo << " are equal" << endl;
- }
- return 0;
- }
- //2.19
- int main(){
- double numOne{0};
- double numTwo{0};
- double numThree{0};
- double numLargest{0};
- double numSmallest{0};
- cout << "Please enter three numbers" << endl;
- cin >> numOne >> numTwo >> numThree;
- if (numOne > numTwo) {
- numLargest = numOne;
- }
- else {
- numLargest = numTwo;
- }
- if (numLargest < numThree) {
- numLargest = numThree;
- }
- if (numOne < numTwo) {
- numSmallest = numOne;
- }
- else {
- numSmallest = numTwo;
- }
- if (numSmallest > numThree) {
- numSmallest = numThree;
- }
- cout << "Sum is " << numOne + numTwo + numThree << endl;
- cout << "Average is " << (numOne + numTwo + numThree)/ 3 << endl;
- cout << "Product is " << numOne * numTwo * numThree << endl;
- cout << "Smallest is " << numSmallest << endl;
- cout << "Largest is " << numLargest << endl;
- return 0;
- }
- //2.20
- int main(){
- double pi{3.14159};
- int r{0};
- cout << "Please type a radius: " << endl;
- cin >> r;
- cout << "Diameter: " << 2*r << "\n" << "Circumference: " << 2*pi*r << "\n" << "Surface Area: " << pi*r*r << endl;
- return 0;
- }
- //2.28
- int main(){
- int r{0};
- cout << "Please type a 5 digit integer" << endl;
- cin >> r;
- cout << (r / 10000) << " " << (r / 1000) % 10 << " " << (r / 100) % 10 << " " << (r / 10) % 10 << " " << (r) % 10 << " " << endl;
- return 0;
- }
- //2.30
- int main(){
- int weight{0};
- int height{0};
- cout << "Please type your weight in pounds: " << endl;
- cin >> weight;
- cout << "Please type your height in inches: " << endl;
- cin >> height;
- cout << "Your BMI is: " << (weight * 703)/(height*height) << endl;
- cout << "BMI VALUES";
- cout << "Underweight: less than 18.5 \nNormal: between 18.5 and 24.9 \nOverweight: between 25 and 29.9 \nObese: 30 or greater" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement