
Lab 8- Exam 2 Review

Quiz
•
Computers
•
University
•
Medium
Elise Neubarth
Used 9+ times
FREE Resource
19 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What will be displayed to the screen?
#include <stdio.h>
int main()
{
int num1 =20, num2= 2, num3=3;
int small =num1;
if (small>num2)
{
small =num2;
}
if (small>num3)
{
small=num3;
}
printf("%d", small);
return 0;
}
20
2
3
I don't know
Answer explanation
The code will display 2 onto the screen. The first line of the program is setting a temporary variable called "small" to be the same value as num1. We then compare small to num2. If num2 is less than small, we set small to num2. The program will then go to the second if statement. If num3 is less than small, set small to num3.
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What are the three different kinds of loops?
For loop, while loop, if loop
For loop, while do loop, while loop
For loop, do while loop, while loop
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Which loop is the best to use for the following prompt:
Create a program where a user enters multiple numbers. The program should add up all of the numbers until the user enters 0. Example output:
Enter a number: 1.5
Enter a number: 2.4
Enter a number: -3.4
Enter a number: 4.2
Enter a number: 0
Sum = 4.70
do while loop
while loop
for loop
if loop
Answer explanation
We use a while or a do while loop when we want the program to run as long as a specific condition is met. A do while loop will run one time before the condition is tested. Either loop could be used. However, it is best to use a do while loop because we want the code to run at least one time before we test the condition.
We do not use a for loop in this case because we do not know how many numbers the user wants to enter. Therefore, we do not know how many times the loop needs to run.
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which loop would be best to use for the following prompt?
Create a program that displays the temperature as long as it is sunny outside.
do while
while
for
Answer explanation
A while loop would be better for this prompt because we want the temperature to be displayed only when the weather outside is sunny. We could use a do while loop for this example. However, the do while loop would display the temperature before testing if the condition is met.
We would not use a for loop because we do not know how many times the user will enter a value in.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which loop would be best for the following prompt?
Create a program that asks the user to enter multiple numbers and add these numbers together. The user should enter how many values they want to enter. Example output:
How many numbers would you like to enter: 3
Enter number: 23
Enter number: 2
Enter number 5
Sum is 30
do while
while
for
Answer explanation
We will use a for loop since we know how many times the loop needs to run.
You would not use a while or a do while loop because there is not a specific condition that needs to be met.
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Write a function prototype for the following prompt:
Create a function that takes in two integers and one character. The function will return a double. The function will add the two integers.
int function (double num1, int num2, num3, char letter);
double function (int num1, int num2, char letter);
char function (double num1, num2, int num3)
{
double sum=num1+num2;
return 'c';
}
double ans=function(2, 4, 'c');
Answer explanation
The function prototype goes at the top of your code. It goes under the #include <stdio.h> and above the main function. The function prototype looks like the following:
returnType function_name (variable).
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
How do you declare a pointer?
int numptr
point int numptr
int * numptr
Create a free account and access millions of resources
Similar Resources on Wayground
19 questions
Data Types Java Concepts

Quiz
•
University
15 questions
Eval. 1BIM - 1ro B

Quiz
•
7th Grade - University
15 questions
C programming

Quiz
•
University
20 questions
PERULANGAN WHILE DO

Quiz
•
University
20 questions
Quiz

Quiz
•
University
15 questions
code trivia

Quiz
•
University
15 questions
Java Programming

Quiz
•
University
15 questions
Preliminary Round

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University