Concept explainers
Show the output of the following code:
Give the output of a C++ code.
Program Plan: To give the output for the given lines of code:
double area=5.2;
cout <<"area";
cout<
Program Description:
In the given code, a double type variable is assigned the value, 5.2. There are two cout statements. The first cout statement has a string “area� and the second cout statement will
print the value stored in the variable area.
Therefore, the program output will be:
area5.2
Explanation of Solution
Program:
#include
using namespace std;
//Main of the code
int main()
{
//double type variable to store area
double area=5.2;
//cout statement that prints the message “area�
cout <<"area";
//printing the value stored in the variable area
cout<
return 0;
}
Want to see more full solutions like this?
Chapter 2 Solutions
Introduction to Programming with C++
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Using MIS (10th Edition)
Absolute Java (6th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (4th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- C++: Describe how the following call by reference works. Make a comment for each line. void pxc(int& c, int& d) { int k = c; c = d; d = k; } int main() { int a = 15, b = 100; pxc(a, b); }arrow_forwardExplain the steps in finding the output of the following code: #include <iostream>using namespace std; int main() { int arr[5] = {7, 2, 3, 6, 5}; int sum = 0; for (int i = 0; i < 5; ++i) { sum += arr[i]; } cout << " sum : " << sum << endl; return 0;}arrow_forwardplease write a code for thatarrow_forward
- Your C++ code has the following statement Your C++ code has the following statement Float f=1.25; Please write following the method we discussed in class binary single precision floating point representation of f.arrow_forwardYou have to write code c++arrow_forwardIf you run the following code, what will be the data type of variable num2? num1="1a34fd" num2=int(num1,base=16) you will get an error message int float strarrow_forward
- First, write code that uses cin to read in a value for numTomatoes from input. Then, write code that uses cout to output "She sold me ", the variable numTomatoes, and " tomatoes." End with a newline. Ex: If the input is 8, then the output is: She sold me 8 tomatoes. Ex: If the input is 9, then the output is: She sold me 9 tomatoes #include <iostream>using namespace std; int main() { int numTomatoes; /* Your code goes here */ return 0;}arrow_forwardint a = 4, b;b = a-- + 2;What is the value of b in the above code? a. 7 b. 6 c. Error d. 5arrow_forwardint the given statement 10 timarrow_forward
- Integer variable numYards is read from input. Type cast numYards to a double. Ex: If the input is 20, then the output is: 20.00 --Having troublw with this code its supposed to be in C++. #include <iostream>#include <iomanip>using namespace std; int main() {int numYards; cin >> numYards; cout << fixed << setprecision(2) << /* Your code goes here */ << endl; return 0;}arrow_forward2. What data type would you use to allow a function to receive an Int or nil value as its parameter? func display(num: ____ ) { if num == nil { print("Not a number") } else { print(num) } } display(num: 5) display(num: nil)arrow_forwardPlease use the below code to write code for median and standard deviation. I have already written for Average, Min, and Max value. Thanks! #include <stdlib.h> #include <stdio.h> #include <pthread.h> int nums; int* vals; double avg; int min, max; void* myAvg(void* param) { avg = 0.0; for(inti = 0; i < nums; ++i) { avg += vals[i]; } avg /= nums; pthread_exit(0); } void* myMin(void* param) { min = vals[0]; for(inti = 1; i < nums; ++i) { if(min > vals[i]) min = vals[i]; } pthread_exit(0); } void* myMax(void* param) { max = vals[0]; for(inti = 1; i < nums; ++i) { if(max < vals[i]) max = vals[i]; } pthread_exit(0); } int main(int argc, char** argv) { int i; nums = (argc - 1); if(nums <= 0) { printf("you have to give atleat one value!\n"); return1; } vals =…arrow_forward
- 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