What is the output of the following program? (2, 3, 6, 8)
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
double x, y;
string str;
x = 9.0;
y = 3.2;
cout << fixed << showpoint << setprecision (2);
cout << x << "^" << y << " = " << pow(x, y) << endl;
cout << "5.0^2.5 = " << pow(5.0, 2.5) << endl;
cout << "sqrt (48.35) = " << sqrt (48.35) << endl;
cout << "static_cast<int>(sqrt(pow (y, 4))) = "
<< static_cast<int>(sqrt(pow (y, 4))) << endl;
str = "Predefined functions simplify
cout << "Length of str = " << str.length() << endl;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Malik's C++ Programming: From Problem Analysis To Program Design, 8th (mindtap Course List)
- This assignment is not graded, I just need to understand how to do it. Please help, thank you! Language: C++ Given: Main.cpp #include #include "Shape.h" using namespace std; void main() { /////// Untouchable Block #1 ////////// Shape* shape; /////// End of Untouchable Block #1 ////////// /////// Untouchable Block #2 ////////// if (shape == nullptr) { cout << "What shape is this?! Good bye!"; return; } cout << "The perimeter of your " << shape->getShapeName() << ": " << shape->getPerimeter() << endl; cout << "The area of your " << shape->getShapeName() << ": " << shape->getArea() << endl; /////// End of Untouchable Block #2 //////////} Shape.cpp string Shape::getShapeName() { switch (mShapeType) { case ShapeType::CIRCLE: return "circle"; case ShapeType::SQUARE: return "square"; case ShapeType::RECTANGLE: return "rectangle"; case…arrow_forward#include using namespace std; int main() int x=1,y=2; for (int i=0; i<3; i++) e{ x=x*y; 8{ } cout<arrow_forward#include <iostream>using namespace std; struct Person{ int weight ; int height;}; int main(){ Person fred; Person* ptr = &fred; fred.weight=190; fred.height=70; return 0;} What is a correct way to subtract 5 from fred's weight using the pointer variable 'ptr'?arrow_forward// Assume all libraries are included 3 void func (int a, int &b, int &c); // int main () { int i = 5, j = 4, k = 33; 4 7 %3D 8. func (i, j, k); func (j, i, k); cout << j « k << i <« endl; 10 11 12 13 return 0; 14 } // 15 16 void func (int a, int &b, int &c) { 17 18 = 2*c + b; 19 b a; 20 C = a + 3*b; } // 21 22 I|||arrow_forward#include using namespace std3; int main() { int x-6; int y=103; int z=0; int q=1; Z+= X-- -ys q*=++z+y; cout<arrow_forwardDeal or No Deal? Code in C languagearrow_forward#include #include #include struct Point2d { double x; double y; void print() { // example: (2.5,3.64) std::cout << "(" << x << "," << y << ")" << std::endl; } double length() const { return std::sqrt(x * x + y * y); } // const Point2D & ==> function can't modify 'other' // the second const ==> function can't modify x, y Point2d add(const Point2d &other) const { Point2d result; result.x = x + other.x; result.y = y + other.y; return result; } }; // // do NOT modify above this line // Point2d discplacement(std::string commands) { // TODO: re-write this Point2d p = {0, 0}; return p; } // // do NOT modify below this line // void check(Point2d result, double x , double y) { if (result.x != x || result.y != y) { std::cout << "fail" << std::endl; } else { std::cout << "pass" << std::endl; } } int main() { Point2d result =…arrow_forwardNonearrow_forward#include void main(void) { int c =2 ^3; cout<< c; }arrow_forward#include #include using namespace std; void func(); int main(); { func (); func(); system("PAUSE"); return 0; } void func() { int x = 0; static int y = 0; x++; y++; cout << x << "__" << y << endl; } What will the code above print when it is executed?arrow_forward#include using namespace std; void some_action_1(int); int main() { cout<arrow_forwardFind errors / syntax error. Write line numberarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill EducationWhat Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BYData Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License