C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 3, Problem 12SA

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 programming code!";

     cout << "Length of str = " << str.length() << endl;

     return 0;

}

Blurred answer
Students have asked these similar questions
What will be the output of the following program in C++?   #include<iostream> using namespace std; int x = 1; int main() { int x = 2; { int x = 3; cout << ::x << endl; } return 0; }
What will be the output of the following program in C++? #include<iostream>using namespace std;int x = 1;int main(){int x = 2;{int x = 3;cout << ::x << endl;}return 0;}
Question:  Trace and comment each and every line of the C++ program below ; #include <iostream> using namespace std; int binarySearch(int arr[], int left, int right, int num) { if (right >= left) { int mid = left + (right - left) / 2; if (arr[mid] == num) return mid; if (arr[mid] > num) return binarySearch(arr, left, mid - 1, num); return binarySearch(arr, mid + 1, right, num); } return -1; } int main(void) { int arr[] = { 2, 3, 4, 8, 10, 40 }; int check = 40; int n = sizeof(arr) / sizeof(arr[0]); int result = binarySearch(arr, 0, n - 1, check); (result == -1) ? cout << "Element is not present in array" : cout << "Element is present at index " << result; return 0; }
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License