
Lab Review Quiz (2/12/2024-2/16/2024)
Quiz
•
Computers
•
University
•
Practice Problem
•
Medium
Elise Neubarth
Used 11+ times
FREE Resource
Enhance your content in a minute
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Select the correct code for the following prompt:
Write a function definition that asks the user for their first initial, their last initial, and their age.
DO NOT return anything to the main function.
int main()
{
char firstI, lastI;
int age;
printf("Please enter your first initial: ");
scanf("% c", &firstI);
printf("\nPlease enter your last initial: ");
scanf("% c", &lastI);
printf("\nPlease enter your age: ")
scanf("%d", age);
return 0;
}
#include <stdio.h>
void intro();
int main()
{
intro();
return 0;
}
void intro ()
{
char firstI, lastI;
int age;
printf("Please enter your first initial: ");
scanf("% c", &firstI);
printf("\nPlease enter your last initial: ");
scanf("% c", &lastI);
printf("\nPlease enter your age: ")
scanf("%d", age);
}
void intro ()
{
char firstI, lastI;
int age;
printf("Please enter your first initial: ");
scanf("% c", &firstI);
printf("\nPlease enter your last initial: ");
scanf("% c", &lastI);
printf("\nPlease enter your age: ")
scanf("%d", age);
}
void intro ()
{
char firstI, lastI;
int age;
printf("Please enter your first initial: ");
scanf("% c", &firstI);
printf("\nPlease enter your last initial: ");
scanf("% c", &lastI);
printf("\nPlease enter your age: ")
scanf("%lf", age);
}
Answer explanation
The function definition shows what the function is doing. The prompt asked us to create a function that asks the user for their first initial, their last initial, and their age. Therefore, we used a series of printf/scanf statements to get this information. The question said that we would not be returning any values back to the main function. Therefore, we need to use a void function. Since the question only asked for the function definition, we do not need to write the entire program.
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Select the correct code for the following prompt:
Write a function prototype that asks the user for their first initial, their last initial, and their age. These parameters do not come from the main function.
DO NOT return anything to the main function.
void intro();
void intro ()
{
char firstI, lastI;
int age;
printf("Please enter your first initial: ");
scanf("% c", &firstI);
printf("\nPlease enter your last initial: ");
scanf("% c", &lastI);
printf("\nPlease enter your age: ")
scanf("%lf", age);
}
intro();
void intro (char firstI, char lastI, int age);
Answer explanation
The function prototype only includes the function name, the datatype of the variable (if any) that will be returned to the main, and the parameters passed from the main function to the user-defined function. We are told that the function WILL NOT be returning any variables to the main function. Therefore, we know that this will be a void function. We are told that no parameters (variables) are being passed from the main function to our function. Therefore, there is nothing between the parentheses.
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
How many parameters (variables) are being passed from the main function to the following function:
int KC_won(char scripted, int niners, double purdy, char mahomes);
0
1
2
3
4
Answer explanation
When passing parameters (variables) from the main function to our function, we put them in the parentheses. There are four variables in the parentheses. Therefore, the answer is four.
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What datatype is being returned to the main function?
int KC_won(char scripted, int niners, double purdy, char mahomes);
char
double
int
I don't know
Answer explanation
When we write the name of the function, we put the datatype of the variable that we will be returning to the main function at the front. So in the following function: int KC_won(char scripted, int niners, double purdy, char mahomes)
the datatype is integer because it says int at the front.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following is a function prototype?
#include <stdio.h>
int main (void)
{
return 0;
}
int KC_won(char scripted, int niners, double purdy, char mahomes)
{
//code goes here
}
#include <stdio.h>
int main (void)
{
int ans=KC_won(T, 87, 15.5, S);
return 0;
}
#include <stdio.h>
int KC_won(char scripted, int niners, double purdy, char mahomes);
int main (void)
{
return 0;
}
I don't know
Answer explanation
The function prototype goes before the main function.
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What will be displayed to the screen?
int main()
{
int number=4;
if (number%2!=0)
{
printf("This number is odd");
}
else
printf("This number is even");
return 0;
}
This number is odd.
This number is even.
I don't know
Answer explanation
The variable number is equal to 4. This number will be tested against the first condition (number%2!=0) or the remainder of number divided by 2 does not equal zero. Since this is false, the program will print out the printf statement in the else condition.
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What will be displayed to the screen?
int main()
{
int avg=65;
if (avg>=90 && avg<=100)
{
printf("A");
}
else if (avg>=80 && avg<90)
{
printf("B");
}
else if (avg>=70 && avg<80)
{
printf("C");
}
else if (avg>=60 && avg<70)
{
printf("D");
}
else
{
printf("F");
}
return 0;
}
A
B
C
D
F
Answer explanation
The value of avg is 65. This value will be tested against the if/ else if statements until a statement becomes true.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
17 questions
PPS_Activity_Z2_Kiruthika M
Quiz
•
University
10 questions
ภาษาไพธอน
Quiz
•
University
10 questions
Chapter 2 - Communication Skills
Quiz
•
KG - Professional Dev...
13 questions
#include <\c>
Quiz
•
University
10 questions
C Programming Quiz-1
Quiz
•
University
15 questions
C programming
Quiz
•
University
8 questions
Dinamikus tömbök
Quiz
•
University
10 questions
C Programming - Basics 001
Quiz
•
University
Popular Resources on Wayground
10 questions
Forest Self-Management
Lesson
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
30 questions
Thanksgiving Trivia
Quiz
•
9th - 12th Grade
30 questions
Thanksgiving Trivia
Quiz
•
6th Grade
11 questions
Would You Rather - Thanksgiving
Lesson
•
KG - 12th Grade
48 questions
The Eagle Way
Quiz
•
6th Grade
10 questions
Identifying equations
Quiz
•
KG - University
10 questions
Thanksgiving
Lesson
•
5th - 7th Grade
Discover more resources for Computers
10 questions
Identifying equations
Quiz
•
KG - University
7 questions
Different Types of Energy
Interactive video
•
4th Grade - University
20 questions
HS2C2 AB QUIZIZZ
Quiz
•
1st Grade - Professio...
14 questions
Homonyms Quiz
Quiz
•
KG - University
16 questions
Parts of a Parabola
Quiz
•
8th Grade - University
10 questions
A Brief History of Geologic Time
Interactive video
•
11th Grade - University
15 questions
Black Friday/Cyber Monday
Quiz
•
9th Grade - University
7 questions
Biomolecules (Updated)
Interactive video
•
11th Grade - University
