CIT 330 Final Fall 2024

0.0(0)
studied byStudied by 0 people
0.0(0)
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/47

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:53 PM on 12/9/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

48 Terms

1
New cards

What is the right way to access values of structure variables: struct books { int price; int page;} book;

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

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

printf("%d%d", price::book, page::book);

printf("%d%d", price->book, page->book);, a.partName);

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

2
New cards

Given the following definitions, what is the value of b[1][0]?

int b[2][2] = {{1,2}, {3, 4}};

0

1

3

this isn't a valid definition

3

3
New cards

What is the output of the following program:

#include

int main() {

struct Point {

int x;

int y;

float z; } p1;

p1.y=0;

p1.z=1;

p1.x=2;

printf("%d %d %.2f", p1.x, p1.y, p1.z);

return 0; }

2 0 1.00

4
New cards

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

s = "wildcrazy"

5
New cards

What will be the output of the following?

#include

int main() {

struct p {

int k;

char c; };

int p = 10;

struct p x;

x.k = 10;

printf("%d %d\n", x.k, p); }

10 10

6
New cards

Which of the following does not initialize all of the array elements to 0?

int b[2][2];

b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0;

int b[2][2] = {0};

int b[2][2];

for (int i = 0; i < 2; ++i) {

for (int j = 0; j < 2; ++j) {

b[i][j] = 0;

}

}

All of the above initialize all of their elements to 0.

All of the above initialize all of their elements to 0.

7
New cards

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

string1[] = "test";

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

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

string1[] = " ";

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

8
New cards

What will be the output of the following?

#include

int main() {

struct {

int k;

char c;

};

struct p;

p.k = 10;

printf("%d\n", p.k);

}

10

9
New cards

Correct the following code of the errors so that the program runs without errors?

#include

int main () {

struct employee {

int id;

char name[20];

} emp;

employee.id = 8;

printf(%d , id);

return 0;

}

#include

int main () {

struct employee {

int id;

char name[20];

} emp; // The structure variable `emp` is declared here.

emp.id = 8; // Correctly reference the `id` member of the structure variable `emp`.

printf("%d\n", emp.id); // Correctly format the `printf` statement and reference `emp.id`.

return 0;

}

10
New cards

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

int n[5] = {7};

int n[5] = {6, 6, 6};

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

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

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

11
New cards

Constant variables ______

-can be assigned values in executable statements

-can be used to specify array sizes, but this makes programs harder to

-understand

-can be used to specify array sizes, thereby making programs more scalable --do not have to be initialized

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

12
New cards

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

When you input the following data: 2 0 1

int k[6] = {0, 0, 0, 0, 0, 0};

int i, n;

for (i = 3; i < 6; ++i) {

scanf("%d", &n);

k[n] = i;

}

k[1] is 5

k[3] is 0

k[1] is 5

k[3] is 2

k[1] is 5

k[3] is 1

k[1] is 5

k[3] is 3

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

13
New cards

_______ may contain different data types.

structures

arrays

arrays and structures

Neither arrays nor structures

structures

14
New cards

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

pointer

integer

double quote

sequence of characters contained in single quotes

sequence of characters contained in single quotes

15
New cards

What will be the output of the program? #include int main() { int x=55; printf("%d, %d, %d, %d\n", x<=55, x=40, x<=10); return 0; }

compilation error

16
New cards

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 = 10 a = 5

17
New cards

What is the output of the following code fragment?

int x;

char z = 'a';

if (x = z) printf("One");

else printf("Two");

One

18
New cards

Point out the error in the following program error or warning.

#include

int main()

{

display();

return 0;

}

void display()

{

printf("IndiaBIX.com");

}

display() is called before it is defined

19
New cards

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

debugging

20
New cards

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

relational operators

21
New cards

What is the output of the following code fragment?

int x = 10;

int y = 7;

if(2 x > 3 y)

printf("Hello");

else

printf("Bye");

Bye

22
New cards

Which operator would make the following expression True?

False _______ True

OR

23
New cards

Text enclosed in / / in a C program _________.

causes syntax error

gives instructions to the processor

is ignored in the C compiler

makes files available

is ignored in the C compiler

24
New cards

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

-----------------------------

x > 200

100 < x <= 200

0 < x < 100

100 <= x <= 200

———————————————

100 < x <= 200

25
New cards

What will be the output of the program?

#include

int main()

{

int a=100, b=200, c;

c = (a == 100 || b > 200);

printf("c=%d\n", c);

return 0;

}

---------------------------------

c= 100

c= 200

c= 300

c =1

c=1

26
New cards

Which of the following is NOT a data type of a variable?

number

float

character

integer

number

27
New cards

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

&temp,&num

&num,&temp

num,temp

&temp, &num

28
New cards

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

header

body

data

type

definition

body

29
New cards

Given the following C Code, rewrite the program code to correct these errors.

1: / What's wrong with this program? /

2: #include stdio.h

3: int main();

4: }

5: int a, b, c \ Three integers /

5: a = 3

6: b = 4

7: c = a + b

8: printf("The value of c is %d" + C);

9: return 0;

10: }

Line 1: / What's wrong with this program? /#include

int a, b, c; / Three integers /

Line 8: printf("The value of c is %d" , c)

30
New cards

What will be the output of this program fragment?

int value = 0;

do {

printf ("%d", value%2);

value = value +1;

} while (value <5);

01010

31
New cards

How many times will the following loop iterate?

int j = 1;

while (j>5) {

printf("%d", j);

}

No iterations

32
New cards

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

33
New cards

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

34
New cards

What will be the output of this program fragment?

int i =0;

while (i<3) {

printf ("%d%d", i, 5-i);

i=i+1;

}

051423

35
New cards

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

36
New cards

What will be the output of the program?

#includeint main(){ int x=55; printf("%d, %d, %d, %d\n", x<=55, x=40, x<=10); return 0;}

1, 40, 0

37
New cards

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.

38
New cards

What is the subscript index for the data value 92 in the example given below?

int score [5] = {83, 92, 78, 94, 71}

One

39
New cards

How many times will the following loop iterate?

int k =1; while (k<=5) { printf("%d", k); }

Infinite

40
New cards

What will be the output of this program fragment?

int i =0;

while (i<3) {

printf ("%d%d", i, 5-i);

i=i+1;

}

05 15 23

41
New cards

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

for loop

42
New cards

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

Ascending

43
New cards

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

}

infinite loop

44
New cards

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

45
New cards

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

46
New cards

What is the output of the following code fragment?

int i;

for(i = 0 ; i<2 ; i++){

printf("ans1");

printf("ans2");}

ans1ans2ans1ans2

47
New cards

How many times is the loop body of the while statement executed?

int g = 0;

int s = 0;

int t = 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

48
New cards

Suppose a program contains the code

for (i = 1; i < 10; i++) {

n[i] = 1;

}

It is initializing successive elements of an array.

Explore top flashcards

OMM II Terms (4)
Updated 1012d ago
flashcards Flashcards (40)
peds exam 1
Updated 739d ago
flashcards Flashcards (95)
Cognition 2
Updated 1044d ago
flashcards Flashcards (60)
Final practice
Updated 1157d ago
flashcards Flashcards (106)
EP Test 1
Updated 1158d ago
flashcards Flashcards (63)
E1T2: La familia
Updated 87d ago
flashcards Flashcards (74)
OMM II Terms (4)
Updated 1012d ago
flashcards Flashcards (40)
peds exam 1
Updated 739d ago
flashcards Flashcards (95)
Cognition 2
Updated 1044d ago
flashcards Flashcards (60)
Final practice
Updated 1157d ago
flashcards Flashcards (106)
EP Test 1
Updated 1158d ago
flashcards Flashcards (63)
E1T2: La familia
Updated 87d ago
flashcards Flashcards (74)