Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1.Evaluate the following expressions with 3 and 7 as operands 7 / 3 3 / 7 7 % 3 3 % 7 Q2.Given the constant

Q1.Evaluate the following expressions with 3 and 7 as operands 7 / 3 3 / 7 7 % 3 3 % 7

Q2.Given the constant and variable declarations

#define E 2.78

#define MAX 100 double x, y;

int a, b, i;

indicate which of the following statements are valid and where valid, give the value stored into the target variable. Assume that a is 4, b is 3, and y is -2.0.

(a )

i = a % b;

(b)

i = (MAX 90) / a;

(c )

i = a % b * b;

(d)

x = a / y;

(e)

x = E * y;

(f)

i = a * E;

(g)

x = E / y;

(h)

x = b / a;

(i)

x = a % (a / b);

(j)

x = b % (b / a);

(k)

x = (double) a / b;

(l)

x = (double) (a / b);

Q3.

Redo the above question with new values of 3 for a, 7 for b, and 3.0 for y.

Q4.The printf function prints a value of 1025 using a decimal format. What is the output produced (use an underscore character to indicate a space) for the following formats.

%1d %4d %5d %6d

Now repeat this exercise for the value -1025 (negative of the above value).

%1d %4d %5d %6d

Q5.For the floating point values of 108.435, -0.033, -37.886, 4.56, and -998.5, what is the output produced by printf (u/scores for spaces again) with the format %6.2f.

Q6.If you wish to read in 3 values (one double, and 2 integers) from the keyboard, what format string would you pass to the scanf library function.

Q7.Trace the execution of the following expressions using an evaluation tree. Use the values as follows: i = 5, j = 7, k = 4, m = 6, n = 8, flag1 = 0, flag2 = 1 (all integers), and a = 3.5, b = 8.0, c = 0.0, d = 40.0 (doubles).

n (i + j / 2) + k * m

3 * (a b) / (2 * (c d))

!flag1 && flag2 && (a <= b) && (k*m < 20)

Q9.Write a function in C that will take in Cartesian coordinates (x, y) as two doubles and will return an integer which is the quadrant number of that particular point. Assume that the x and y axes themselves are on the positive side of each half-plane.

Q10.Write a function that will accept two integers as input and will return the sum of all the integers from the first value, up to and including the second value. Assume the integers are always passed to the function with the lower value first and the higher value second. How would you cater for the inputs being out of order?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions