
Final Exam Review

Quiz
•
Computers
•
University
•
Medium
Elise Neubarth
Used 4+ times
FREE Resource
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.
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
C++ Functions

Quiz
•
University
15 questions
BASIC C PROGRAMMING

Quiz
•
University
10 questions
Informatika x

Quiz
•
University
15 questions
Java

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

Quiz
•
University
13 questions
ÔN TẬP C - mảng 1 chiều

Quiz
•
University
10 questions
PROGRAMACION

Quiz
•
9th Grade - University
15 questions
BASIC C PROGRAMMING QUIZ

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

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

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

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

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University