CIT 330 WKU Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is the value of variable "s" after execution of the program fragment below? char h[6] = "wild"; char p[6] = "crazy"; char s[10]; strcpy(s, h); strcat(s, p);

"wildcrazy"

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 is the value of the expression that follows? strcmp("5", "49");

1

What is the value of the expression that follows? strcmp("dog", "Dog");

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, 12.0, -54.5}; int j = 5; printf("%.2f\t", x[j] + 1); printf("%.2f\t", x[j + 1]);

13.00 14.00

In the fragment below, what is the minimum size of result required for successful and valid concatenation of "double" and "trouble"? strcpy(result, "double"); strcpy(result, "trouble");

15

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? #include <stdio.h> 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

What value is return by the following call to strlen? strlen("robot")

5

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; else z = z + 1; i = i + 1; }

6 times

A valid reason for building programs out of functions is:

All of the above

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

What does the following function do? int func(int n){ int ans; if (n == 1) ans = 1; else ans = n + func(n-1); return (ans);

Computes (addition of numbers .. (n-1) + n) using a recursive definition.

What does the following function do? int c_digits(const char *str){ int ans; if (str[0] =='\0') ans = 0; else if (isdigit(str[0])) ans = 1 + count_digits(&str[1]); else ans = count_digits(&str[1]); return (ans); }

Counts the number of digits in the string str

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

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

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

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

It is initializing successive elements in an array.

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

No iterations

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.

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

ans1ans2ans1ans2

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 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

What does the deck[52] array contain in the following statement? struct card a, deck[52], *cPtr;

card structure elements

The function prototype double mySqrt(int x);

defines a function called mySqrt which takes an integer as an argument 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

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);

To test whether a character is one of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, use the _________ standard library function.

isdigit

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 does the following function do? int func(int m, int n){ int ans; if (n == 0) ans = m; else ans = 1 + func(m, n-1); return (ans); }

performs two integer addition

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

pointer

If the printf function is passed a character array that is not null terminated it will:

print the contents of the character array and keep printing characters in memory until it encounters a null character

Which function does NOT read data from standard input?

printf

What is the right way to access values of structure variable book{price, page}?

printf{"%d %d", book.price, book.page);

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{ unsigned int partNumber; char partName[25]; }; Reading the a part number and the a part name from the keyboard into the individual members of a structurepart variable called a.

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

Which function returns the length of a string, not including the null terminator?

strlen

Keyword _________ introduces the structure definition.

struct

_______ may contain different data types.

structures


Set pelajaran terkait

Chapter 13: The peripheral nervous system

View Set

MGMT 3050 - International Business - Study Guide Exam 2

View Set

Praxis 5004 Geography, Sociology, and Anthropology

View Set

Fundamentals test 3 (CH. 21-communication)

View Set

Chapter 3 | Uniform Securities Act - Administration and Fraudulent Act

View Set

日本語のまねきねこ・だい1か

View Set