Practice Problem 2.54 (solution page 160)
Assume variables x, f, and d are of type int, float, and double, respectively. Their values are arbitrary, except that neither f nor d equals +∞, –∞, or NaN. For each of the following C expressions, either argue that it will always be true (i.e.,evaluate to 1) or give a value for the variables such that it is not true (i.e., evaluates to 0).
- A. x == (int)(double) x
- B. x == (int) (float) x
- C. d == (double)(float) d
- D. f == (float)(double) f
- E. f == -(-f)
- F. 1.0/2 ==1/2.0
- G. d*d >=0.0
- H. (f+d)-f == d
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Software Engineering (10th Edition)
Concepts of Programming Languages (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Python (4th Edition)
- (true or false) Indicate for each of the following three statements whether it is true or false. Motivate your answers! a) Consider a primal-dual pair of linear programs. Claim: If the dual problem is infeasible then the primal problem is unbounded. b) Consider the problem to minxeR» ƒ(x) where f : R" → R is a twice differentiable function (i.e., ƒ e C²). Claim: If Vf(x*)= 0 and V²f(x*) ► 0 then æ* is a local minimum of f. %3D c) Consider the Frank-Wolfe method used for minimizing a non-linear function over a polyhedron. Claim: In each iteration of the algorithm a linear program needs to be solved in order to find the search direction.arrow_forwardPROBLEM 12. [TIME ALLOWED = 5 MINUTES] Give the contrapositive and converse of the following proposition: “If it is sunny, then I will go swimming.”arrow_forwardProblem 8. (Optional) Construct a random variable X (by specifying its pmf) whose con responding Huffman code is {0, 10, 11}. cor-arrow_forward
- Problem 2: (Basic Problems: True or False) Specify the following state- ments are true (T) or false (F). Specify some BRIEF arguments (say, no more than 3 lines). • (2.1) Since Bayesian estimation only yields a posterior distribution, thus it is impossible for Bayesian estimation to suggest some single point estimation for parameter. • (2.2) MLE estimates views the parameter as deterministic and should work well in case your sample set is of small size. • (2.3) For rectangle matrix A, AA' and A' A are both non-negative definite, and have the same eigenvectors.arrow_forwardExample 7: Rocket sleds were used to test aircraft and its effects on human subjects at high speeds. It is consisted of four rockets; each rocket creates an identical thrust T. Calculate the magnitude of force exerted by each rocket (T) for the four-rocket propulsion system shown in the Figure. The sled's initial acceleration is 49 m/s, the mass of the system is 2100 kg, and the force of friction opposing the motion is known to be 650 N. Solution: H.W Free-body diagramarrow_forwardRedo problem 2 where you have to define and use the following functions: (a) isTriangle - takes 3 sides of a triangle and returns true if they form a triangle, false otherwise. (b) isIsosceles - takes 3 sides of a triangle and returns true if they form an isosceles triangle, false otherwise. (c) isEquilateral - takes 3 sides of a triangle and returns true if they form anequilateral triangle, false otherwise. (d) isRight - takes 3 sides of a triangle and returns true if they form a right triangle, false otherwise. (e) your program should run continuous until the user wants to quit this is my problem 2: #include <iostream> #include <cmath> using namespace std; // Constant Declarations const double E = .0001; int main() { double side1, side2, side3; bool isTriangle, isRight, isEquilateral, isIsosceles; cout << "Enter the lengths of the 3 sides of a triangle -- "; cin >> side1 >> side2 >> side3; isTriangle = side1 + side2 > side3 &&side1 +…arrow_forward
- PROBLEM 17. [TIME ALLOWED = 5 MINUTES] State whether “n is divisible by 9” is (a) necessary, (b) sufficient, or (c) neither necessary nor sufficient for “n is divisible by 6”, where n is a natural number.arrow_forwardProblem 11. (i) Consider the following arithmetic problem ab*c de + fg hi where a, b, c, d, e, f, g, h, i stand for a nonzero digit, i.e., they are elements of the set {1,2,3, 4, 5, 6, 7,8, 9}, * denotes multiplication and + addition. Each nonzero digit occurs only once in the problem. Is there a solution? If so, is the solution unique? (ii) Write a C++ program that finds a solution (if one exists).arrow_forwardPyhton Help, As soon as possible You and your friend sell 80 tickets to a raffle. You sold 20 more than your friend. The goal of this problem is to find how many tickets you and your friend have sold. (a) Set up the linear equation for this problem as Ax = b, where x = number of tickets your friend sold. (b) Find A-¹ (Please show your steps). (c) Use A-¹ to solve x. (d) Use python to verify that your A-¹ and solution x are correct. Write your answers for part a here, find the Matrix A from scratch. Write your answers for part b here, please calculate A-¹ manually Write your answers for part c here, x = A-¹b, please perform this calculation manually. [] import numpy as np A = np.array(...) b = np.array(...) [] x2 Fill in the blank in the code cell below for part d, please use your own Python code to replace "..." parts. If you prefer, you can write your piece of code from scratch instead (without filling in the blanks). A_inverse = . Let x₁ represent number of tickets you sold, and x2…arrow_forward
- (a) Assume that five generation units with third order cost function (F, (R) = A; P+ B;P+C; P; + D;) are in the circuit. Write a computer program using any abitrary programming longuage (MATLAB, C++, C#, Python,.) to calculate economic load dipatch (ELD) using first order gradient method. Note that all parameters and variables should be defined inside the program (at tirst lines) such that units' characteristics and demand can be changed easily. Neglect grid losses. jusing dynamic programming (DP) methed.arrow_forwardRedo problem 2 triangle.cc where you have to defineand use the following functions:(a) isTriangle - takes 3 sides of a triangle and returns true if they form a triangle,false otherwise.(b) isIsosceles - takes 3 sides of a triangle and returns true if they form an isoscelestriangle, false otherwise.(c) isEquilateral - takes 3 sides of a triangle and returns true if they form anequilateral triangle, false otherwise.(d) isRight - takes 3 sides of a triangle and returns true if they form a right triangle,false otherwise. this is the question and this is my work for problem 2 // This program prompts a user to enter the lengths of// the 3 sides of a triangle, check if they form a triangle,// and prints the triangle type: right, isosceles, equilateral,// or scalene #include <iostream>#include <cmath> using namespace std; // Constant Declarationsconst double E = .0001; int main() { double side1, side2, side3; bool isTriangle, isRight, isEquilateral, isIsosceles; cout <<…arrow_forwardPROBLEM 2 (CONDITIONAL) Write a C program to input 3 sides of a triangle and check whether a triangle is Equilateral, Isosceles or Scalene. Equilateral triangle: An equilateral triangle is a triangle in which all three sides are equal. In the familiar Euclidean geometry, equilateral triangles are also equiangular; that is, all three internal angles are also congruent to each other and are each 60°. Isosceles triangle: An isosceles triangle is a triangle that has two sides of equal length. Scalene triangle: A scalene triangle is a triangle that has three unequal sides, such as those illustrated above. a b c a =c 75 a = b = c 30 45 60 60 a b Scalene Triangle K60° 75 60° Isosceles Triangle Equilateral Traingle Test Data 1 Test Data 2 Test Data 3 Enter side a: 70 Enter side b: 7 Enter side c: 70 Enter side a: 50 Enter side a: 50 Enter side b: 60 Enter side c: 50 Enter side b: 60 Enter side c: 70 Triangle is Isosceles Triangle is Equilateral Triangle is Scalenearrow_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