1 of 25
The ______ of a function take(s) information into the function from the calling statement.
local variables
input arguments
output arguments
prototype
purpose

2 of 25
What is displayed by the C statements below if the value input is 3?
scanf ("%d", &n);
if (n = 5)
printf("Equal\n");
else if (n < 5)
printf("Less\n");
else
printf("Greater\n");
Equal
Less
Greater
No output

3 of 25
What will be the value of i after the C statements below have been executed?
i=3;
j=10;
if ((3 * i) < j)
i=i + 2;
i=i+3;
5
6
8
10
15

4 of 25
This question concerns the following program fragment:
char r, x, y, z, w;

scanf("%c%c%c%c", &x, &y, &z, &w);
if (x < y)
r=x;
else
r=y;
if (r>z)
r=z;
if (r>w)
r=w;
printf("%c\n", r);

The program's effect can best be described as:

It displays the letter 'r' after comparing it to x, y, and z.

Of the four input characters, it displays the one that comes first in the alphabet.

Of the four input characters, it displays the one that comes last in the alphabet.

Of the four input characters, it displays the one that comes second in the alphabet.

It displays nothing since characters cannot be compared.

5 of 25

For what exact range of values of variable x does the following code segment display the letter 'C'?

if (x <= 200)
if (x < 100)
if (x <= 0)
printf("A\n");
else
printf("B\n");
else
printf("C\n");
else
printf("D\n");

0 < x < 100

x <= 0

100 <= x <= 200

x > 200

100 < x <= 200

6 of 25

A special value that marks the end of a list of input data is called a __________.

terminal value

sentinel value

loop control value

input value

loop termination value

7 of 25

The expression: x *= i + j / y; is equivalent to ______.

x = x * i + j / y;

x = (x * i) + j / y;

x = (x * i + j) / y;

x = x * (i + j / y);

none of the above

8 of 25

The effect of the following program segment can best be described as __________.

if (x > y)
z = x;
if (x == y)
z=0;
if (x < y)
z = y;

the smaller of x and y is stored in z.

the larger of x and y is stored in z.

the larger of x and y is stored in z unless x and y are equal, in which case z is assigned zero.

the larger of x and y is stored in z unless x and y are not equal, in which case z is assigned zero.

none of the above.

9 of 25

If the input to the program segment below is 85, what is its output?

scanf("%d", &s);
if (s >= 90)
printf ("A\n");
else if (s >= 70)
printf ("C\n");
else if (s >= 80)
printf ("B\n");
else
printf ("D\n");

A

B

C

D

C

10 of 25

Which of the types listed below can be the type of the result value returned by a user-defined function?

int

double

char

all of the above

none of the above

11 of 25

In function apart defined below, how many of the parameters are considered input parameters?

void apart(double x, int *wholep, double *fracp)
{
*wholep = (int)x;
*fracp = x - *wholep;
}

0

1

2

3

all

12 of 25

What is the complement of the following expression?

n||a <= b && c != 100

!n || a > b || c == 100

!(n && (a > b || c == 100))

!n && (a > b || c == 100)

!(n || (a > b || c == 100))

none of the above

13 of 25

How many lines of output will be displayed by the following program fragment?

i=0;
do
{
for (j = 0; j < 4; j = j + 1)
printf("%d\n", i + j);
i=i + 1;
}
while (i < 5);

0

7

9

16

20

14 of 25

How many times is the loop body of the while statement executed?
Refer to the following program segment. Assume that all variables are of type int.

z=0;
g=0;
s=0;
i=0;
while (i < 50)
{
scanf("%d", &t);
s=s + t;
if (t >= 0)
g=g + 1;
else
z=z + 1;
i=i + 1;
}

once

never

49 times

50 times

until a number 50 or larger is entered

15 of 25

The if statement:

if (13 < 12)
printf("never\n");
else
printf("always\n");

displays never.

displays always.

will not compile since 13 is not less than 12.

causes a run-time error since 13 is not less than 12.

displays nothing since 13 is not less that 12.

16 of 25

The facts that a function assumes to be true of the arguments that it receives are called __________.

function input validations

local variables

postconditions

preconditions

none of the above

17 of 25

Here is the prototype of a function:

void five (double x, double* yp, int* zp);

Given these variable declarations, which calls to five are valid?

int m, n
double p, q

five(m, &p, &n);

q = five(6.2, &p, &m);

five(p, &q, &m);

five(7.1, &p, &q);

a and c only

a, b, c, and d

18 of 25

In a function that receives a value from the main function via a parameter and then displays the parameter value on the screen, that parameter is considered __________.

an input parameter

an output parameter

an input/output parameter

a local variable

a stub

19 of 25

Variables that represent neither problem inputs nor problem outputs but are needed for internal computations are called _____.

problem constants

prototypes

results

formula variables

program variables

20 of 25

Which of the types listed below can be the type of a function output parameter?

int*

double*

char*

all of the above

none of the above

21 of 25

Which one of these is not the name of a C library function?

printf

sqrt

void

scanf

log

22 of 25

Which one of the following lines names a constant needed in a program that computes the price per square inch of a round pizza?

scanf("%lf", &radius);

pi = 3.14159;

#define PI 3.14159

#include <pi.h>

none of the above

23 of 25

The value stored in variable s at the end of the execution of the loop could best be described as __________. Refer to the following program segment. Assume that all variables are of type int.

z=0;
g=0;
s=0;
i=0;
while (i < 50)
{
scanf("%d", &t);
s=s + t;
if (t >= 0)
g=g + 1;
else
z=z + 1;
i=i + 1;
}

the average of the numbers scanned

the sum of the numbers scanned

the largest of the numbers scanned

how many numbers were scanned

the sentinel value

24 of 25

What is the output from this program?

#include <stdio.h>

void do_something(int *thisp, int that)
{
int the_other;

the_other = 5;
that = 2 + the_other;
*thisp = the_other * that;
}

int main(void)
{
int first, second;

first = 1;
second = 2;
do_something(&second, first);
printf("%4d%4d\n", first, second);

return 0;
}

35 2

1 35

35 7

1 2

0

25 of 25

What is displayed by the C statements that follow if the value input is 2?

scanf ("%d", &ctl);
switch (ctl)
{
case 0:
case 1:
printf("red ");
case 2:
printf("blue ");
case 3:
printf("green ");
case 4:
printf("yellow");
}
printf("\n");

red

blue

green

yellow

blue green yellow

Recommended Answers

All 2 Replies

1. Read the rules on homework - you make an effort to answer them, and we'll help you understand your mistakes
2. Read the rules on posting code.

Your score so far - ZERO!!!!!

The only correction I can see, and it's minor, is that postconditions is not a valid English word.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.