CIT 330

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which operator is used to determine that the operands are NOT exactly of the same value?

!=

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"

If num is a variable of type int and temp is a variable of type double, how could you correctly complete this function call? scanf("%f%d", _________);

&temp, &num

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

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

100<=x<=200

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

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

Given the following definitions, what is thevalue of b[1][0]?int b[2][2] = {{1}, {3, 4}};

3

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

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

A valid reason for building programs out of functions is:

All of the above

What is the output of the following code fragment?

Bye

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]);elseans = 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.

What is the output of the following code fragment? int a = 1;switch(a){case 5:printf("John\t");break;case 1:printf("Susan\t");case 2:printf("Dan\t");break;case 3:printf("Bob\t");case 4:printf("Mary\t"); break;break;default :printf("Illegal section number");

Illegal section number

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

It is initializing successive elements of an array

Which operator would make the following expression True? False _______ True

OR

What type of operators are the following? > < >= <= == !=

Relational

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 program fragment? int a=4; void write() { int a=10; printf("a = %d", a); }int main(){ int a = 5; write(); printf("a = %d", a); return 0;}

a=5

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

ba

The smallest storage location in a computer's memory is known as a _______.

bit

The function _________ comprises one or more statements that are executed when the function is called.

body

Unless otherwise specified, entire arrays are passed ______ and individual array elements are passed __________.

call-by-reference, call-by-value

constant variables

can be used to specify array sizes, thereby making programs more scalable.

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

card structure elements

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

___________ process occurs when the programmer finds and corrects the code that is causing the error(s).

debugging

The function prototype double mySqrt(int x);

defines a function called mySqrt which takes an integer as an argument and returns a double

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

displays always

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

green

How many times will the following loop iterate? Set k = 1 While k < = 5 Display k End While

infinite

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 does not initialize all of the array elements of 0?

int b[2][2]; for (int I= 0; I <2; ++I){for (int j = 0; j < 2;++j){b[I][j] = 0 } }

Which of the following is NOT a correct way to initialize an array?int n[5] = {0, 7, 0, 3, 8, 2};int n[] = {0, 7, 0, 3, 8, 2};int n[5] = {7};int n[5] = {6, 6, 6};

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

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

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

Text enclosed in /* */ in a C program _________.

is ignored by the C compiler

10110000 is an example of an instruction written in which computer language?

machine language

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

no iterations

Which of the following is NOT a variable data type?

number

What is the output of the following code fragment? int x; char z = ' b '; if (x = z) printf("One"); else printf("Two");

one

What is the subscript for the data value 92 in the example given below? Declare Integer score [5] = 83, 92, 78, 94, 71 - One - Two - A - B - None of these

one

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

Assume string1 is a character array. Which of the following operations does not produce a string?

string1[]={'t', 'e', 's', 't'};

________ may contain different data types

structures

The term used for a set of rules that must be strictly followed when writing a program is:

syntax

Passing an argument to a function by ________ means that only a copy of the argument's value is passed into the parameter variable.

value


Ensembles d'études connexes

Macroeconomics Practice Questions

View Set

Benchmark Adelante Unidad 3 Semana 1

View Set

Fundamentals Final Exam Practice review

View Set

BCOR 2205: Info Management Midterm

View Set

Combo with Manual Muscle Tests of the hand and wrist and 4 others

View Set