
Final Exam Review
Authored by Elise Neubarth
Computers
University
Used 4+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
13 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Declare a double array called grocery_List. Make the array with a size of 30.
double grocery_List[30];
double grocery_List=30;
grocery_List=30;
Answer explanation
When declaring an array, you do the following:
datatype arrayname[size of array]. For this example,
double grocery_List[30];
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Use a loop to enter elements into the following array:
double grocery_List[30];
scanf("%lf",&grocery_List);
for (int i=0; i<=30; i++)
{
scanf("%lf", &grocery_List[i]);
}
for (int i=0; i<30; i++)
{
scanf("%lf", &grocery_List[i]);
}
for (int i=0; i<30; i++)
{
scanf("%lf", &grocery_List);
}
Answer explanation
When entering elements into an array, you need to use a loop. The easiest loop to use with arrays are for loops. When you want to access a specific element within an array, you need to do the following:
arrayname[index].
Therefore, when we use a for loop to enter values within an array, we write the following:
for (int i=0; i<30; i++)
{
scanf("%lf", &grocery_List[i]);
}
When the loop runs the first time, we are adding a value into the first index of the array or grocery_List[0] because i=0. When we run the loop again, we enter the value into grocery_List[1] because i=1. This will continue for the entirety of the loop.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Write the function call for the following function prototype:
double total (double list[]);
int main ()
{
double grocery_List[30];
// code that enters values into the array
total(grocery_List);
return 0;
}
int main ()
{
double grocery_List[30];
// code that enters values into the array
double sale=total(grocery_List[30]);
return 0;
}
int main ()
{
double grocery_List[30];
// code that enters values into the array
double total(grocery_List);
return 0;
}
int main ()
{
double grocery_List[30];
// code that enters values into the array
double sale=total(grocery_List);
return 0;
}
Answer explanation
When you pass the entire array from the main function to the programmer defined function, you write the following:
sale=total(grocery_List);
//where sale was previously declared as a double datatype
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Write a function definition that returns a double and accepts the following array from the main function:
double grocery_List[30]
Name the function: total
The function will calculate the total of the array.
double total (double list[])
{
double sum=0.0;
for (int i=0; i<30; i++){
sum+=list;
}
return sum;
double total (double list[])
{
double sum=0.0;
for (int i=0; i<30; i++){
sum+=list[i];
}
return sum;
double total (double list[30])
{
double sum=0.0;
for (int i=0; i<30; i++){
sum+=list[i];
}
return sum;
double total (double list[])
{
double sum=0.0;
for (int i=0; i<=30; i++){
sum+=list[i];
}
return sum;
Answer explanation
When we pass an array from the main function to a programmer defined function, we write the following:
returntype functionname (datatype arrayname[])
or
double total (double list[]).
When calculating the sum of the array, you need to use a loop.
When we are using a variable to store the sum, we need to initialize this variable to be 0 before we perform any calculations (0.0 if the answer is a double).
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Write a definition of a struct type for the following prompt:
Create a struct to store employee information such as employee ID, position, and salary.
struct employee{
int employeeID;
char position [100];
double salary;
};
struct typedef{
int employeeID;
char position [100];
double salary;
} employees;
typedef struct{
int employeeID;
char position [100];
double salary;
} employees;
typedef employees{
int employeeID;
char position[100];
double salary;
};
Answer explanation
When we write a struct definition, we write it as follows:
typedef struct{
//fields of your struct
} structname;
Dr. Sorgente did introduce you to a different way of writing structs (C++). However, she has mentioned that you need to write them as stated above.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Declare employee1 as a part of the employee struct.
typedef Struct{
int employeeID;
char position [100];
double salary;
} employees;
employee1;
int main ()
{
employees employee1;
return 0;
}
int main ()
{
struct employee1
return 0;
}
I don't know
Answer explanation
When we want to declare a variable as a part of the struct, we use the struct name as the "data type" for the variable. Therefore, if the struct name is employees, when we declare a variable, employee1, we say
employees employee1 within the main function.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Ask the user to enter the employeeID, the position of the employee, and the salary for the employee. Please use the following struct for reference:
typedef struct{
int employeeID;
char position [100];
double salary;
} employees;
int main void(){
employees employee1;
scanf("%d", &employee1.employeeID);
scanf("%s", employee1.position);
scanf("%lf", &employee1. salary);
}
int main void(){
scanf("%d", &employeeID);
scanf("%s", position);
scanf("%lf", &salary);
}
int main void(){
employees employee1;
scanf("%d", &employees.employeeID);
scanf("%s", employees.position);
scanf("%lf", &employees. salary);
}
Answer explanation
When we are accessing different fields within the struct, we use the ".". For example, when we want to access employee1's ID, we say:
employee1.employeeID.
Since we previously declared employee1 to be a variable for the struct, employees, we will use employee1 and not employees.
Access all questions and much more by creating a free account
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
13 questions
CIS1103 Week 9_10 CLO3 Part 3
Quiz
•
University
10 questions
2025 python class first quiz
Quiz
•
9th Grade - University
12 questions
R variable Data Type and Flow Control Quiz
Quiz
•
University
14 questions
LA5.C5: Branching and Subroutines
Quiz
•
9th Grade - University
15 questions
Python
Quiz
•
University
15 questions
SENATIC Parcial Guía 3_PseInt
Quiz
•
10th Grade - University
10 questions
T02: Python - The Basics
Quiz
•
University
10 questions
INTRODUCCION A LA PROGRAMACION
Quiz
•
6th Grade - University
Popular Resources on Wayground
8 questions
Spartan Way - Classroom Responsible
Quiz
•
9th - 12th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
14 questions
Boundaries & Healthy Relationships
Lesson
•
6th - 8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
3 questions
Integrity and Your Health
Lesson
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
9 questions
FOREST Perception
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
Discover more resources for Computers
20 questions
Disney Trivia
Quiz
•
University
7 questions
Fragments, Run-ons, and Complete Sentences
Interactive video
•
4th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
10 questions
DNA Structure and Replication: Crash Course Biology
Interactive video
•
11th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
14 questions
Ch.3_TEACHER-led
Quiz
•
University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University