wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CODE 4 KITSW ROUND - 4

Total questions: 15

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of using structures in C programming?

a)

To perform mathematical operations

b)

To group variables of different data types

c)

To define functions

d)

To print output

2.

What is the output of the below pseudo code?

struct Student {

int roll_number;

char name[20]; };

int main() {

struct Student s;

s.roll_number = 101;

strcpy(s.name, "John Doe");

printf("%d %s", s.roll_number, s.name);

return 0; }

a)

101

b)

101 John Doe

c)

Error

d)

John Doe

3.

How do you access a member of a structure variable in C?

a)

Using the dot operator (.)

b)

Using the arrow operator (->)

c)

Using the star operator (*)

d)

Using the hash operator (#)

4.

What will be the output of the above pseudo code?

union Data {

int num;

char letter;

};

int main() {

union Data d;

d.num = 65;

printf("%d %c", d.num, d.letter);

return 0;

}

a)

65 A

b)

65

c)

Error

d)

A

5.

Which of the following is true about arrays of structures in C?

a)

Arrays can store structures of the same type

b)

Arrays can store structures of different types

c)

Arrays can only store integers

d)

Arrays cannot store structures

6.

What will be the output of the above pseudo code?

void swap(int *a, int *b) {

int temp = *a;

*a = temp;

*b =*a;

}

int main() {

int x = 5, y = 10;

swap(&x, &y);

printf("%d %d", x, y);

return 0;

}

a)

10 10

b)

5 10

c)

5 5

d)

10 5

7.

Which operator is used to access the value pointed to by a pointer in C?

a)

Hash operator (#)

b)

Arrow operator (->)

c)

Dot operator (.)

d)

Star operator (*)

8.

What will the content of the "data.txt" file after executing the above pseudo code?

FILE *fp; int main() {

fp = fopen("data.txt", "w");

fprintf(fp, "Hello, World!");

fclose(fp);

return 0;

}

a)

Hello, World!

b)

Nothing

c)

Error

d)

Undefined

9.

How do you define and open a file in C?

a)

define_file(file_name);

b)

open_file(file_name);

c)

fopen(file_name, mode);

d)

create_file(file_name);

10.

What is the output of the above pseudo code?

struct Point {

int x; int y; };

int main() {

struct Point p = {3, 7};

struct Point *ptr = &p;

printf("%d %d", ptr->x, ptr->y);

return 0;

}

a)

3 7

b)

7 3

c)

Undefined

d)

Error

11.

What is the syntax to declare a structure in C?

a)

struct name { }

b)

structure { }

c)

struct { }

d)

structure name { }

12.

What will be printed when the above pseudo code is executed?

void printString(char *str) {

while (*str != '\0') {

printf("%c", *str);

str++;

}

}

int main() {

char message[] = "Hello";

printString(message);

return 0;

}

a)

Undefined

b)

Error

c)

Hello

d)

H

13.

What are sequential text files used for in file management in C?

a)

Encrypting data

b)

Sorting data alphabetically

c)

Reading and writing data sequentially

d)

Storing data in a random order

14.

What will be the output of the above pseudo code?

struct Book {

char title[50];

float price;

};

int main() {

struct Book books[3] = {{"Book1", 25.5}, {"Book2", 30.0}, {"Book3",15.75}};

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

printf("%s %.2f\n", books[i].title, books[i].price);

}

return 0;

}

a)

Undefined

b)

Error

c)

Book1 Book2 Book3\n25.50 30.00 15.75\n

d)

Book1 25.50\nBook2 30.00\nBook3 15.75\n

15.

How do you perform input and output operations on a sequential text file in C?

a)

Using scanf and printf functions

b)

Using read and write functions

c)

Using fopen, fprintf, and fclose functions

d)

Using malloc and free functions