Question

24) A C program has the following declarations: float x = 10.0, y = 5.5, z...

24) A C program has the following declarations: float x = 10.0, y = 5.5, z = 2.1; int i = 3, j = 5, k = 7, m; EVALUATE each of the following expressions. SHOW YOUR WORK, including the type of each sub expression (indicating a float with a decimal point). If the expression would compile and runs but would produce garbage output, mark GARBAGE and EXPLAIN. If you are not confident of your answer, type in, compile and run an appropriate program.

(a) y / x (b) i % j (c) k + z (d) 100 / i – x (e) 324 / m - 12 (f) i % (j - 3) % 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

y/x will print 0.550000 on the console. because y and x both are floats. float divide by float is float

b)

i % j will print 3 because (i=3) is less than (j=5).

c)

k+z will print 9.10000 if the output is stored in float variable. because k is int and z is a float.

d) 100 / i – x will print 23.000000

because 100/3 =33, 33-10.0 =23.000000

e) 324 / m - 12 will compile and run.

But it does not give any output on console because m is undefined.

f)

i % (j - 3) % 3 will give 1 as output

because 3%2 = 1, 1%3=1

Add a comment
Know the answer?
Add Answer to:
24) A C program has the following declarations: float x = 10.0, y = 5.5, z...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • After the following declarations and statements are executed:       int i, j, k ;       boolean...

    After the following declarations and statements are executed:       int i, j, k ;       boolean c;       float x, y,   z;       int[ ] num = {4, 1, 2, 3, 8};       i = 3;       j = 5;       x = 4.3;       y = 58.209;       c = !(i > j) ; what is the value of c

  • 1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf...

    1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...

  • Consider a C function negMat(), that negates each element of a K x K matrix y[][],...

    Consider a C function negMat(), that negates each element of a K x K matrix y[][], and stores each result into the matrix x[][] : void negMat(float *x, float *y, int K) { int i, j; for (i=0; i<K; i++) { for (j=0; j<K; j++) { x[i * K + j] = - y[i * K + j]; } } } negMat() runs on the CPU (obviously), and x[][]and y[][] are stored in row-major order. Write a CUDA kernel negMatGPU(),...

  • 9. Which of the following is true for the following program? #include <stdio.h> int maino int...

    9. Which of the following is true for the following program? #include <stdio.h> int maino int i = 1; switch (0) case 1: printf("%d", 0); case 2: printf("%d", 0); case 3: printf("%d", 0); default: printf("%d", 1); return 0; } (2 points) The program has no error, the output is 1111 The program has no error, the output is 1 The program produces a compile time error, because there are no break statements The program produces a compile time error, because...

  • My C++ program is give me extra characters in my output. Below is an example of input.txt and the section of code that reads it. input.txt (x/y), x = 20, y = 5; ((y>x)&(x<z)),x=5,y=10,z=3; o...

    My C++ program is give me extra characters in my output. Below is an example of input.txt and the section of code that reads it. input.txt (x/y), x = 20, y = 5; ((y>x)&(x<z)),x=5,y=10,z=3; output I get: Value=4 20, y=5; Value=0z)), x=5, y=10, z=3; ifstream fin;         fin.open("input.txt");     while (true)     {         symbolTable.init();         fin.getline(line, SIZE);         if (!fin)             break;         stringstream in(line, ios_base::in);         in >> paren;         cout << line << " ";         expression = SubExpression::parse(in);         in >> comma;         parseAssignments(in);         double result = expression->evaluate();         cout...

  • QUESTION 3 Assume x = 4 and y = 5, which of the following is true?...

    QUESTION 3 Assume x = 4 and y = 5, which of the following is true? x < 5 || y < 5 x > 5 || y > 5 x < 5 && y < 5 x > 5 && y > 5 QUESTION 14 Which of the following statements are the same? (A) x -= x + 4 (B) x = x + 4 - x (C) x = x - (x + 4) (A) and (B) are...

  • Spell it out! Use the following Java concepts to compile the program below:   String myName =...

    Spell it out! Use the following Java concepts to compile the program below:   String myName = "Chuck";     int length = myName.length();     char firstChar = myName.charAt(0);     char secondChar = myName.charAt(1);     if (myName.equals("Tom")) {       System.out.println ("Sorry, Tom!");   } Write a program that uses a METHOD to translate these individual characters:   input output input output input output input output input output a 4 g 9 m /\\/\\ s $ y ‘/ b B h |-| n |\\| t...

  • Consider F and C below. F(x, y, z) = yz i + xz j + (xy...

    Consider F and C below. F(x, y, z) = yz i + xz j + (xy + 10z) k C is the line segment from (3, 0, -3) to (4, 4, 1) (a) Find a function f such that F = Vf. f(x, y, z) = (b) Use part (a) to evaluate [s vf. dr along the given curve C.

  • Let C be the curve (x - 3)2 + 9(y – 1)2 = 36, x +2y...

    Let C be the curve (x - 3)2 + 9(y – 1)2 = 36, x +2y + z = 4, oriented counterclockwise when viewed from high on the z-axis. Let F be as shown below. Evaluate $.F. F.dr. F= (32² + 3y² + sin x? )i + (6xy + 3z)j + (x2 + 2yz)k $. F. dr= (Type an exact answer.) с

  • This is a c++ question note: not using  namespace std; at the beginning of the program Writing...

    This is a c++ question note: not using  namespace std; at the beginning of the program Writing Data to a File This program will write a series of letters, starting with 'A', to an external file (letters.txt). The user will decide how many letters in total get saved to the file. ** IMPORTANT: The test cases will evaluate your code against .txt files that I uploaded. You do NOT have to upload your own txt files. Input: Including 'A', how many...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT