330 final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What will be the output of this program fragment? int value = 0; do { printf ("%d", value); value = value +2; } while (value <5);

024

What will be the output of this program fragment? int i =0; while (i<3) { printf ("\t%d %d", i, 5-i); i=i+1;}

05 14 23

How many of the parameters are considered input parameters in the function below?voidapart (double x, int *wholep, double *fracp) { *wholep = (int)x; *fracp = x - *wholep; }

1

What will be the output of this program fragment? int value = 1;do {printf ("%d\n", value);value = value +2;} while (value <5);

1 3

What will be the output of the following? #include <stdio.h> struct p { int k; char c; }; int p = 10; int main() { struct p x; x.k = 10; printf("%d %d\n", x.k, p); }

10 10

What is the output of the following program fragment? double x[8] = {16.0, 12.0, 6.0, 8.0, 2.5, 12.0, 14.0, -54.5};int j = 5;printf("%.2f\t", x[j] + 1); printf("%.2f", x[j + 1]);

13.00 14.00

What is the output of the following program: #include<stdio.h> struct Point{ int x, y, z;}; int main() { struct Point p1 = {.y = 0, .z = 1, .x = 2}; printf("%d %d %d", p1.x, p1.y, p1.z); return 0; }

2 0 1

What is the output of the following code fragment? int x=0; while(x<=3){printf("%d\t", x + 2);x++;}

2 3 4 5

What is the output of the following program? void bing(int n) { printf("%4d ", n);} int main(void) { double x; x = 41;bing(x);printf("%.2f\n", x);return (0); }

41 41.10

Given the following: #define MAX 50 int a[MAX]; What is the maximum valid subscript value for array a?

49

how many numbers can be stored in the array declared below double arr[10][5];

50

How many times is the loop body of the while statement executed? int g = 0;int s = 0;int z = 0;int i = 0;while (i <=5) {scanf("%d", &t);s = s + t;if (t >= 0)g = g + 1;elsez = z + 1;i = i + 1;}

6 times

When the elements in an array are stored from lowest to highest, the array is sorted in __________ order.

Ascending

What will be the output of the following? #include <stdio.h> struct { int k; char c; }; int main() { struct p; p.k = 10; printf("%d\n", p.k); }

Compile time error

What will be the output of the following? #include <stdio.h> void main() { struct student { int no; char name[20]; }; struct student s; no = 8; printf("%d", no); }

Compile time error

How would you best describe the purpose of the following code? f = 0; for (i = 1; i < N; ++i) if (a[i] >= a[f]) f = i;

Determine the subscript of the last occurrence of the largest of the first N components of array a.

Consider the following code fragment: char str[10]; scanf("%s", str); What will happen if scanf encounters the string "vivaciously" when scanning a value for str?

Function scanf will store the entire string "vivaciously", even though there is insufficient space in str. The string will overflow str.

How many times will the following loop iterate? int k =1; while (k<=5) { printf("%d", k); }

Infinite

What does the following C function do? int fun(const char *string) { char blank = ' '; int k; int looking = 1; k = strlen(string); while (k >= 0 && looking) { if (string[k] == blank) --k; else looking = 0; } if (looking) return (-1); else return (k); }

It finds the subscript of the last nonblank character in string.

Suppose a program contains the code for (i = 1; i < = 10; i++) { n[i] = 1; }

It is initializing successive 10 elements of an array.

Suppose a program contains the code for (i = 1; i < = 10; i++) { n[i] = 1; }

It is initializing successive elements of an array.

How many times will the following loop iterate? int j = 1; while (j>5) { printf("%d", j); }

No iterations

What is the subscript index for the data value 92 in the example given below? int score [5] = {83, 92, 78, 94, 71}

One

What value is returned by function result? int result(const int a[], int n) { int i, r; r = 0; for (i = 1; i < n; ++i) if (a[i] > a[r]) r = i; return (r); }

The subscript of the largest of the first n elements of array a.

Which of the following statement is true about the statement below? int score [5] = {83, 92, 78, 94, 71};

This is an array declaration and initialization.

Which character marks the end of a string?

\0

A valid reason for building programs out of functions is:

all of the above

When passing an array of 10 elements of an array called data to a function, the formal parameter declaration looks like:

all of the above

What is the output of the following code fragment? int i;for(i = 0 ; i<2 ; i++){ printf("ans1"); printf("ans2"); }

ans1ans2ans1ans2

What will be the output of this program fragment? char u, v, temp;u = 'a';v = 'b'; while ( v != 'a' ) { temp = u; u = v; v = temp; } printf ("%c %c", u, v);

ba

The function prototype double mySqrt(int x);

defines a function called mySqrt which takes an integer as an argu-ment and returns a double

Which of the following code segments does not contain any errors?

double triple(float n) {return (3 * n);}

GIven below prototype of a function: void five(double x, double *yp, int *zp); Given these variable declarations:int m, n;double p, q; What could be a valid call to function five()?

five(6.2, &p, &n);

Which loop is specifically designed to initialize, test, and increment a counter variable?

for loop

Two arrays with the same number of elements and related data are called _______ arrays.

identical

What will be the output of this program fragment? int i; for(i = 0 ; i=1 ; ++i){ printf("ans1"); printf("ans2"); }

infinite loop

Which of the following is NOT a correct way to initialize an array?

int n[5] = {0, 7, 0, 3, 8, 2};

What will be the values of k[1] and k[3] after execution of the code segment below using the data shown?

k[1] is 5 k[3] is 0

What is the subscript index for the data value 92 in the example given below? int score [5] = {83, 92, 78, 94, 71}

one

In C, it is appropriate to say that a string is a(n) __________.

pointer

which function does not read data from standard input

printf

int square(int); is an example of a function __________.

prototype

Which of the following is optional when writing a function definition?

return statement

Given the following structure definition: struct part { int partNumber; char partName[25]; } ; Reading a part number and a part name from the keyboard into the individual members of a structure part variable called a.

scanf("%d%24s", &a.partNumber, a.partName);

Function strcmp returns __________ if its first argument is equal to its second argument.

specifically 0

Keyword __________ introduces the structure definition.

struct

____ may contain different data types

structures

When a C program passes an array as a function argument,

the address of the initial element of the array is actually passed.

What is displayed by the code fragment below if the memory for next immediately follows the memory for word?

the word "cat" followed by whatever garbage is in word[3] through word[11] followed


Kaugnay na mga set ng pag-aaral

Penny Abdomen - Ch. 3 Gallbladder Quiz

View Set

ТАБЛИЦА СЛОВООБРАЗОВАНИЯ (F)

View Set

Man. of Strat. All 13 chapter Ultimate Final Study Guide

View Set

Energy, Catalysis & Biosynthesis - Cell Bio Test 2

View Set

Ecology Chapter 4- Coping with Environmental Variation

View Set

Developmental Psychology: Childhood

View Set