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

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan 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.


Set pelajaran terkait

Spinal exam 1 Practice Questions

View Set

Biology Unit 4 Chapter 5 - Energy and Ecosystems

View Set

Romeo and Juliet: Act 1 Scene 1 Quotes

View Set