
Lab Review Quiz (2/12/2024-2/16/2024)

Quiz
•
Computers
•
University
•
Medium
Elise Neubarth
Used 11+ times
FREE Resource
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
Similar Resources on Wayground
13 questions
ÔN TẬP C - mảng 1 chiều

Quiz
•
University
16 questions
Lógica de Programação

Quiz
•
University
10 questions
POST TES MATRIKULASI

Quiz
•
10th Grade - University
10 questions
Expression in C Programming

Quiz
•
University
12 questions
Operators in C

Quiz
•
University
15 questions
BASIC C PROGRAMMING QUIZ

Quiz
•
University
10 questions
PROGRAMACION

Quiz
•
9th Grade - University
12 questions
UNIT 3

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

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

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University