NEW
Font size
WorksheetsCODE 4 KITSW ROUND - 4
Total questions: 15
Worksheet time: 5mins
What is the purpose of using structures in C programming?
To perform mathematical operations
To group variables of different data types
To define functions
To print output
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; }
101
101 John Doe
Error
John Doe
How do you access a member of a structure variable in C?
Using the dot operator (.)
Using the arrow operator (->)
Using the star operator (*)
Using the hash operator (#)
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;
}
65 A
65
Error
A
Which of the following is true about arrays of structures in C?
Arrays can store structures of the same type
Arrays can store structures of different types
Arrays can only store integers
Arrays cannot store structures
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;
}
10 10
5 10
5 5
10 5
Which operator is used to access the value pointed to by a pointer in C?
Hash operator (#)
Arrow operator (->)
Dot operator (.)
Star operator (*)
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;
}
Hello, World!
Nothing
Error
Undefined
How do you define and open a file in C?
define_file(file_name);
open_file(file_name);
fopen(file_name, mode);
create_file(file_name);
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;
}
3 7
7 3
Undefined
Error
What is the syntax to declare a structure in C?
struct name { }
structure { }
struct { }
structure name { }
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;
}
Undefined
Error
Hello
H
What are sequential text files used for in file management in C?
Encrypting data
Sorting data alphabetically
Reading and writing data sequentially
Storing data in a random order
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;
}
Undefined
Error
Book1 Book2 Book3\n25.50 30.00 15.75\n
Book1 25.50\nBook2 30.00\nBook3 15.75\n
How do you perform input and output operations on a sequential text file in C?
Using scanf and printf functions
Using read and write functions
Using fopen, fprintf, and fclose functions
Using malloc and free functions
