O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

You'll find answers to the review questions in Appendix B, “Answers to Review Questions.”

1:Assume all variables are of type int. Find the value of each of the following variables:
  1. x = (2 + 3) * 6;

  2. x = (12 + 6)/2*3;

  3. y = x = (2 + 3)/4;

  4. y = 3 + 2*(x = 7/2);

2:Assume all variables are of type int. Find the value of each of the following variables:
  1. x = (int) 3.8 + 3.3;

  2. x = (2 + 3) * 10.5;

  3. x = 3 / 5 * 22.0;

  4. x = 22.0 * 3 / 5;

3:You suspect that there are some errors in the next program. Can you find them?
int main(void)
{
  int i = 1,
  float n;
  printf("Watch out! Here come a bunch of fractions!\n");
  while (i < 30)
    n = 1/i;
    printf(" %f", n);
  printf("That's all, folks!\n");
  return;
}
4:Here is a first attempt at making min_sec interactive, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required