DOC PREVIEW
CSUN COMP 106 - Solutions to First Quiz

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

College of Engineering and Computer ScienceComputer Science DepartmentComputer Science 106 Computing in Engineering and ScienceSpring 2006 Course number: 11672 Instructor: Larry CarettoSolutions to First Quiz1. (15 points) What is the value of the variable on the left side of the assignment statements shown below after the statement is executes? The variables have the following definitions and data types. double a = 25.5, b = 10.0; int z;a) z = a / bz = 25.5/10.0 = 2.55 = 2 after substation into the int variable zb) a = a / ba = 25.5/10.0 = 2.55c) a = int( a / b )a = int(25.5/10.0) = int(2.55) = 2 (converted to double for a)d) a = int( a )/ int( b )a = int(25.5)/(10.0) = 25/10 = 2 (converted to double for a)e) a = int( a )/ b a = int(25.5)/(10.0) = 25/10.0 = 25.0/10.0 = 2.52. (15 points) Write the correct C++ statements to represent the following equations. Recall that the sqrtfunction can be used to compute square roots.a)23 xyxbaww = ( a = b * x / y ) / ( 3 * x + 2 );b)aacbbx242x = ( -b + sqrt( b * b – 4 * a c ) ) / ( 2 * a );c)32dxcxbxap p = a + b * x + c * x * x + d * pow( x, 3 );Jacaranda (Engineering) 3333 Mail Code Phone: 818.677.6448E-mail: [email protected] 8348 Fax: 818.677.7062d)HighwayCityAverage45.055.01average = 1 / ( 0.55 / city + 0.45 / highway);e)rxrxrwqwpp = w / q * ( w / r – x ) / (r – x / r );3. (30 points) The height, h, of an object that is shot into the air with an initial velocity v0 is determined by this initial velocity and the acceleration of gravity, g. The object reaches a maximum height, hmax, at a time, tmax, then returns to the ground at a time tfinal. The values of hmax, tmax, and tfinal are given by the following equations. In these formulas, with SI units, g = 9.807 m/s2, h is in meters, t is in seconds and v0 is in meters per second.gv2tgvtg2vh0final0max20maxWrite a complete C++ program that defines and sets a symbolic constant for g then prompts a user to enter the initial velocity, v0, in meters per second. The program should then compute and print out, with appropriate descriptions and units, the values of hmax, tmax, and tfinal.#include <iostream>#include <cmath>using namespace std;int main(){ cout << “This program computes trajectory parameters\n\n” << “Enter the initial velocity in meters per second: “; double v0;\ cin >> v0; const double g = 9.807; double hMax = v0 * v0 / g; double tMax = v0 / g; double tFinal = 2 * v0 / g; cout << “\n\nThe maximum height is “ << hMax << “ meters.” << “\nThe maximum height occurs at “ << tMax << “ seconds.” << “\nThe final time is “ << tFinal << “ seconds.”; return EXIT_SUCCESS;}Jacaranda (Engineering) 3333 Mail Code Phone: 818.677.6448E-mail: [email protected] 8348 Fax:


View Full Document

CSUN COMP 106 - Solutions to First Quiz

Download Solutions to First Quiz
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Solutions to First Quiz and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Solutions to First Quiz 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?