int quiz & Expressions quiz (C for Everyone: Programming Fundamentals - Week 2 Coursera)

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Assume that int a = 3, b = 4, c = -2; What is the value of a + b?

7

Assume that int a = 3, b = 4, c = -2; What is the value of ++a + b++?

8

#include <stdio.h> int main(void) { int miles = 26, yards = 385; int kilometers; kilometers = 1.609 * (miles + yards/1760.0); printf("\nA marathon is %d kilometers.\n", kilometers); return 0; } What does this program print, because of int kilometers?

A marathon is 42 kilometers.

Assume that int a = 3, b = 4, c = -2; What is the value of ++a + c?

2

Assume that int a = 3, b = 4, c = -2; What is the value of a / b?

0

Assume that int a = 3, b = 4, c = -2; What is the value of -a + b?

1

Assume that int a = 3, b = 4, c = -2; What is the value of b / a?

1

#include <stdio.h> int main(void) { int miles = 26, yards = 385; int kilometers; kilometers = 1.609 * (miles + yards/1760.0); printf("\nA marathon is %d kilometers.\n", kilometers); return 0; } Why do we use the format specifier %d instead of %lf?

lf (as in %lf, not "if") is a double and the int answer would print incorrectly.


Ensembles d'études connexes

Spinal exam 1 Practice Questions

View Set

Biology Unit 4 Chapter 5 - Energy and Ecosystems

View Set

Chapter 13: Supply Chain Management and Marketing Channels

View Set

Unit 1 Progress Check: MCQ Part B

View Set