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
EBK C PROGRAMMING:
- C LANGUAGE. According to the instructions, the function will be written. ArrayList search_restaurantsarrow_forwardQuestion 8 Find the score (mean accuracy) of your knn classifier using x_test and y_test. This function should return a float between 0 and 1 [ ]: def answer_eight(): # YOUR CODE HERE raise NotImplementedError() [ ]:arrow_forwardq7.arrow_forward
- Static_cast (8•6+Statie_cast (17)/3)=arrow_forwardC PROGRAM / C LANGUAGEMake a C program array. Situation:Conduct a survey for investigatory project to ask how satisfied the students are with the current state of our school. Use a rating system of 1 to 10. There are a lot of people who answered the survey and you could not accurately tally the number of people who answered 1, or 10, or any other number in between.arrow_forwardRetrieve information from this webpage "https://www.chewy.com/b/dry-food-294", Dry Dog Food. The information you need is 1) the brand and the name of the products, 2) the price for auto ship, and 3) the regular price. For Q1 and Q2, you may need the function trimws() or gsub() to remove unwanted characters.arrow_forward
- Please help with the assignment! Language is C. Answer as simply as you can as it is an Intro to C class. Write two functions, total_product and total_sum. Both functions return an integer. Total_product function takes in a 2D array of integers along with an integer with the number of rows and columns. This function will return an integer with the product of the sum of the rows. See example for details. The total_sum function takes in an array of integers with the size of the array. The total_sum function will find the sum of the 1D array. You must call the total_sum function in the total_product to receive full credit. Example: row/column 0 1 2 3 total_sum(row) Result 0 1 2 3 4 10 1 5 6 7 8 26 Given this 2D array above, the answer for total_product would be 260. Because row one adds up to be 10, and row two adds up to be 26. We multiple this together to get total product.arrow_forwardIN C PROGRAMMING LANGUAGE PLEASE DO THE FOLLOWING USING STRUCTURES IN C , An iron manufacturing company maintains data about all of its employees, including every employee’s name, unique ID, age, native city, contact number, the department to which she or he belongs, and gross salary. The company wants a program that can sort the employees based on their native city in order to easily trace how many employees belong to the same region. Write a program module by using ‘strcmp’ to sort all the available names of cities in an ascending order.arrow_forwardtypedef _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 cell People_T *ptr ; Declare a pointer pointing to the structure data and print the age and name using the pointer. your output can be : 30 Cathy 40 John 50 Tomarrow_forward
- code in c++arrow_forwardCount consecutive summers def count_consecutive_summers(n): Like a majestic wild horse waiting for the rugged hero to tame it, positive integers can be broken down as sums of consecutive positive integers in various ways. For example, the integer 42 often used as placeholder in this kind of discussions can be broken down into such a sum in four different ways: (a) 3 + 4 + 5 + 6 + 7 + 8 + 9, (b) 9 + 10 + 11 + 12, (c) 13 + 14 + 15 and (d) 42. As the last solution (d) shows, any positive integer can always be trivially expressed as a singleton sum that consists of that integer alone. Given a positive integer n, determine how many different ways it can be expressed as a sum of consecutive positive integers, and return that count. The number of ways that a positive integer n can be represented as a sum of consecutive integers is called its politeness, and can also be computed by tallying up the number of odd divisors of that number. However, note that the linked Wikipedia de0inition…arrow_forwardExplain the values of int data type.arrow_forward
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT