Programming in C - W4
Question 1
What statement would you use to print the phrase “Hello, world” and then start a new line?
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 2
What statement would you use to assign the value 32 to the variable cheeses?
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 3
What statement would you use to read a value from keyboard input into the variable cheeses?
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 4
What statement would you use to print “We have X varieties of cheese,” where the current value of the cheeses variable replaces X?
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 5
Write a C program that displays your name and address (or if you value your privacy, a fictitious name and address).
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 6
Declare variables matching the following descriptions:
a. A short integer with the value 80
b. An unsigned int integer with the value 42,110
c. An integer with the value 3,000,000,000
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 7
Evaluate the following expressions as C++ would:
a. 8 * 9 + 2
b. 6 * 3 / 4
c. 3 / 4 * 6
d. 6.0 * 3 / 4
e. 15 % 4
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 8
What is the variable type for each of the following declarations?
a. auto cars = 15;
b. auto iou = 150.37f;
c. auto level = 'B';
d. auto crat = U'/U00002155';
e. auto fract = 8.25f/2.5;
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 9
Construct logical expressions to represent the following conditions:
a. weight is greater than or equal to 115 but less than 125.
b. ch is q or Q.
c. x is even but is not 26.
d. x is even but is not a multiple of 26.
e. donation is in the range 1,000–2,000 or guest is 1.
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Question 10
Convert the following to a do/while loop. It should produce exactly the same output.
#include
int main(){
int i=0, k=0;
float j=0;
int counter = 10;
printf("Begin counting");
for (i=0; i < counter; i++) {
printf(i);
}
return 0;
}
|
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Content Editor
|
10 points
Save and Submit
Click Save and Submit to save and submit. Click Save All Answers to save all answers.
essay-ans-_62329
Arial
3 (12pt)
essay-ans-_62329
Paragraph
-- Font family --
-- Font size --
Arial
H
essay-ans-_62329
Arial
3 (12pt)
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
Paragraph
H
essay-ans-_62329
Arial
3 (12pt)
-- Font family --
Paragraph
-- Font family --
-- Font size --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
essay-ans-_62329
Arial
3 (12pt)
Paragraph
-- Font family --
-- Font size --
H
H