a. num1 = 35;
Explanation of Solution
num1 = 35; is a valid assignment as integer 35 is be...
b. newNum = num1 – num2;
Explanation of Solution
newNum = num1 – num2; is a valid assignment although the variables num1 and num2 have not been initialized. If a variable is used in an expression, the expression would yield a meaningf...
c. num1 = 5; num2 = 2 + num1; num1 = num2 / 3;
Explanation of Solution
num1 = 5; num2 = 2 + num1; num1 = num2 / 3; are valid assignments. num1 =5; declares and initializes the variable num1. num2 = 2 + num1; assigns the value of the expression 2 + num1 to num2. Since num1 has been declared and assigned a value, the right-hand expression value is 2 + 5 = 7...
d. num1 * num2 = newNum;
Explanation of Solution
num1 * num2 = newNum; is not a valid assignment as the left hand of a valid assignment is a variable and not an expression...
e. x = 12 * num1 - 15.3;
Explanation of Solution
x = 12 * num1 - 15.3; is a valid assignment although the variable num1 in the expression on the right-hand side has been declared but not initialized before being used in the expression. If a variable is used in an expression, the expression would yield a meaningful value only if the variable has first been initialized...
f. num1 * 2 = newNum + num2;
Explanation of Solution
num1 * 2 = newNum + num2; is not a valid assignment as the left hand of a valid assignment is a variable and not an expression...
g. x / y = x * y;
Explanation of Solution
x / y = x * y; is not a valid assignment as the left hand of a valid assignment is a variable and not an expression...
h. num2 = num1 % 2.0;
Explanation of Solution
num2 = num1 % 2.0; is not a valid assignment as the expression on the right-hand side would not evaluate. The expression on the right-hand si...
i. newNum = static_cast<int> (x) % 5;
Explanation of Solution
newNum = static_cast<int> (x) % 5; is a valid assignment. The double variable is explicitly cast to an int type before it participates as an oper...
j. x = x + y - 5;
Explanation of Solution
x = x + y - 5; is a valid assignment although the variables x and y have not been initialized before being used in the expression. The expression on the right side...
k. newNum = num1 + static_cast<int> (4.6 / 2);
Explanation of Solution
newNum = num1 + static_cast<int> (4.6 / 2); is a valid assignment. The expression on the right-hand side evaluates an unpredictable but int type value. The expression inside the parentheses is evaluated first where the denominator is implicitly casted to floating-point type (as the numerator is floating-point type)...
Trending nowThis is a popular solution!
Chapter 2 Solutions
C++ Programming: From Problem Analysis to Program Design
- Programarrow_forwardHef sharks_minnows (minnows, sharks): shark_count = 0 minnow_count = len (minnows) for i in range(minnow_count): curr_shark_height = minnows [i] if curr_shark_height is not None: minnows [i] = None for j in range (i + 1, minnow_count): if minnows [j] == curr_shark_height: minnows [j] = None curr_shark_height -- 1 shark_count += 1 return shark_count <= sharks The provided code is imperfect, in that it sometimes returns True when it should return False, and sometimes returns False when it should return True. (a) Provide an example of a function call where the provided code will correctly return True (i.e. a True Positive) (b) Provide an example of a function call where the provided code will correctly return False (i.e. a True Negative) (c) Provide an example of a function call where the provided code will incorrectly return True (i.e. a False Positive) (d) Provide an example of a function call where the provided code will incorrectly return False (i.e. a False Negative)arrow_forwardName at least four fields in a segment descriptor.arrow_forward
- q7.arrow_forwardYou have the following workspace in MATLAB: Workspace Name Value Beccentricity Egrav_const Binclination Emass_Earth Horbit_period Bradius_Earth E semi_major E spacecraft_loc 6918900 E spacecraft_vel 7.5883e+03 2.8300e-04 6.6730e-11 28.4700 5.9720e+24 95.4320 6378000 6917100 In the box below, fill in the exact command necessary to delete the variable spacecraft_vel from the workspace without deleting any other variables clear spacecraft_vel Question 2 In MATLAB, you are calculating friction forces on five rail materials for a comparison study. One variable you must define is the time traveled on the aluminum rail. Which of the following are appropriate, descriptive variable names that could be used for this variable? Select all that apply. timeAl alum time Alt U aluminum timearrow_forwardStatic_cast (8•6+Statie_cast (17)/3)=arrow_forward
- A "generic" data structure cannot use a primitive type as its generic type. O True Falsearrow_forwardin c language typedef _people { int age; char name[ 32 ] ; } People_T ; People_T data [ 3 ]; Using string lib function, Assign 30 and Cathy to the first cell, Assign 40 and John to the second cell and Assign 50 and Tom to the third cellarrow_forwardWrite in C language Description You have 2 tables, courses and scores. courses consists 3 columns, sid, student_id, and course_id. scores consists 2 columns,sid and score. Please find that how many students failed on at least one course. Input First line consists 2 integers m and n, shows number of rows in courses and scores. Followed m lines are records of courses. student_id are 8-digits numbers begin with non-zero digit. sid and scores are positive integers smaller than 1000. Followed n lines are records of scores. sid are positive integers smaller than 1000. score are integers in range [0, 100]. Output Student will be flunked when his/her average score in the course less than 60. Output is 2 integers shows number of student and student failed on at lease one course. Sample Input 1 2 4 1 10800001 5 2 10800002 5 1 90 1 29 2 65 2 60 Sample Output 1 2 1arrow_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