Question

In: Electrical Engineering

Directly copy the source code and paste into the Word file. Screenshot of running result must...

Directly copy the source code and paste into the Word file. Screenshot of running result must be presented.

1. (20 points) Write the “Hello, world!” program.

2. (30 points) Write a program to calculate the sum from -5 to10. Use the for loop to do the calculation.

3. (20 points) Write a complete C++ program that asks the user to enter the necessary information about the cylinder, calculate the volume in a function (named as calculate_vol, using reference to pass the volume value out), then display the cylinder volume in main function. The volume of cylinder is:

Vol_Cylinder = πr2h

Where π is 3.14159265, r is the radius, and h is the height.

4. (30 points) Declare a vector container. Using keyboard to input several integer numbers, say at least six integer numbers; find the smallest number and display the result.

Solutions

Expert Solution

Answer:-1) The program is-

#include <iostream>
using namespace std;

int main()
{
cout <<"Hello World!";

return 0;
}

OUTPUT:- Hello World!

--------------------------------------------------------------------------------------------

Answer:-2) The code in c++ is-

#include <iostream>
using namespace std;

int main()
{
int sum = 0, i;

for(i = -5; i <= 10; i++) {
sum += i;
}
cout <<"The sum of the integers from -5 to 10 is: " << sum;

return 0;
}

OUTPUT:- The sum of the integers from -5 to 10 is: 40

--------------------------------------------------------------------------------------------

Answer:-3) The program is-

#include <iostream>
using namespace std;

#define PIE 3.14159265

void calculate_vol (double, double, double *);
int main()
{
double volume, radius, height;

cout <<"Enter the value of the radius: ";
cin >> radius;
cout <<"Enter the value of the height: ";
cin >> height;

calculate_vol(radius, height, &volume);

cout <<"\nThe volume of the cylinder is: " << volume << " cubic unit";

return 0;
}

void calculate_vol (double r, double h, double *vol)
{
*vol = PIE * r * r * h;
}

OUTPUT:- Enter the value of the radius: 1
Enter the value of the height: 2

The volume of the cylinder is: 6.28319 cubic unit


Related Solutions

using C thank you Must submit as MS Word file with a screenshot of the 3...
using C thank you Must submit as MS Word file with a screenshot of the 3 outputs. Run your program 3 times. the output must be in a screenshot not typed for the each time you run the program. thank you Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will...
Your hardcopy submission will consist of these two things: Source code (your java file). Screenshot of...
Your hardcopy submission will consist of these two things: Source code (your java file). Screenshot of Eclipse showing output of program. (JPG or PNG format only) Write a program to play the game of Stud Black Jack. This is like regular Black Jack except each player gets 2 cards only and cannot draw additional cards. Create an array of 52 integers. Initialize the array with the values 0-51 (each value representing a card in a deck of cards) in your...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program // This program uses a function that returns a value. #include <iostream> using namespace std; // Function prototype int sum(int num1, int num2); int main() {    int value1 = 20,   // The first value        value2 = 40,   // The second value        total;         //...
Part 2– R work (must be done in R) Copy and paste your R code and...
Part 2– R work (must be done in R) Copy and paste your R code and output into a word document, along with your written answers to the questions, and upload to Canvas.   Follow these instructions to import the necessary dataset: Before opening the dataset needed for this problem, you’ll need to call the “car”package.  Run the following line of code: > library(car) Now you can import the “Prestige” dataset and use it to answer the question below. Name the data...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
It is straightforward to copy-paste code to achieve repetitive actions, what is the downside of such...
It is straightforward to copy-paste code to achieve repetitive actions, what is the downside of such an approach?
R studio questions Write up your answers and paste the R code Copy and paste all...
R studio questions Write up your answers and paste the R code Copy and paste all plots generated. First create a sample drawn from a normal random variable. R has many distributions for which you can get probabilities and draw random numbers. We are going to use the normal. Go to help in R and type in rnorm. You will see a write up for functions associated with the normal distribution. dnorm is the density; pnorm is the probability distribution...
Answer each question completely. Copy and Paste the SPSS output into the word document for the...
Answer each question completely. Copy and Paste the SPSS output into the word document for the calculations portion of the problems, highlighting correct answers. (Please remember to answer the questions you must interpret the SPSS output). A researcher is interested to learn if there is a linear relationship between the hours in a week spent exercising and a person’s life satisfaction. The researchers collected the following data from a random sample, which included the number of hours spent exercising in...
Below is my source code for file merging. when i run the code my merged file...
Below is my source code for file merging. when i run the code my merged file is blank and it never shows merging complete prompt. i dont see any errors or why my code would be causing this. i saved both files with male names and female names in the same location my source code is in as a rtf #include #include #include using namespace std; int main() { ifstream inFile1; ifstream inFile2; ofstream outFile1; int mClientNumber, fClientNumber; string mClientName;...
Economic interdependence is a source of peace in East Asia: Discuss. (700 words) No copy paste,...
Economic interdependence is a source of peace in East Asia: Discuss. (700 words) No copy paste, plz
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT