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;         //...
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 and post it for other students to debug. To be able to receive your full discussion points, you need to submit the following. Following is your check list and rubric       Attach your .cpp file/s with an implemented bug - 20pnts       Describe what the code...
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...
You must write the code in 80x86 assembly language and must attach a screenshot of the...
You must write the code in 80x86 assembly language and must attach a screenshot of the output. # Pennies for Pay Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT