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

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

University

13 Qs

quiz-placeholder

Similar activities

DDL

DDL

University

15 Qs

Analog and Digital Transmission

Analog and Digital Transmission

University

10 Qs

TDC1231 Lec2 Quiz

TDC1231 Lec2 Quiz

KG - University

10 Qs

Quiz LTP 1

Quiz LTP 1

University

10 Qs

Analysis of Algorithms

Analysis of Algorithms

University

10 Qs

loop for(C)

loop for(C)

9th Grade - University

10 Qs

Concept Test for C & C++ Programming

Concept Test for C & C++ Programming

University - Professional Development

10 Qs

C Quiz

C Quiz

University

12 Qs

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

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

Assessment

Quiz

Computers

University

Practice Problem

Medium

Created by

Elise Neubarth

Used 11+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?