
Q121
Q121 What does the following C code do?
int main() {
int arr[] = {1, 2, 3};
int *p = arr;
printf("%d", *(p + 1));
return 0;
}
Prints the first element of arr
Prints the second element of arr
Prints the third element of arr
Error
Q122
Q122 Pseudocode:
SET a TO 10, POINTER p TO ADDRESS OF a, PRINT VALUE AT p
Prints 10
Prints the address of a
Error
None of the above
Q123
Q123 Identify the error in this C code:
int main() {
int *p; *p = 10;
printf("%d", *p);
return 0;
}
Uninitialized pointer
Syntax error
No error
Wrong printf format
Q124
Q124 Find the error:
int main() {
int arr[3] = {1, 2, 3};
int *p = arr;
printf("%d", *p + 2);
return 0;
}
Pointer arithmetic error
Syntax error
No error
Wrong printf format
Q125
Q125 Which function is used to determine the length of a string in C?
strlen
strcmp
strncpy
strchr
Q126
Q126 How do you declare an array of strings in C?
char *arr[];
string arr[];
char arr[][];
char **arr;
Q127
Q127 In C, which function is used to reverse a string?
strrev
strinvert
reverse
invert
Q128
Q128 How does the strncpy function differ from strcpy?
strncpy limits the number of characters copied
strncpy reverses the string
strncpy concatenates the string
No difference
Q129
Q129 What is the output of this C code?
int main() {
char str[] = "Hello World";
printf("%d", strlen(str));
return 0;
}
11
12
10
Error
Q130
Q130 What does the following C code do?
int main() {
char str1[] = "Hello", str2[20];
strcpy(str2, str1);
strrev(str2);
printf("%s", str2);
return 0;
}
Copies str1 to str2 and reverses it
Concatenates str1 and str2
Compares str1 and str2
None of the above
Q131
Q131 Pseudocode:
FUNCTION FindChar(STRING str, CHAR ch) FOR EACH character IN str IF character EQUALS ch RETURN True END FOR RETURN False
Searches for a character in a string and returns true if found
Reverses the string
Concatenates the string
None of the above
Q132
Q132 How do you access a member of a structure using a structure pointer in C?
With the dot operator (.)
With the arrow operator (->)
With the ampersand (&)
With the asterisk (*)
Q133
Q133 What is an enumerated data type in C?
A data type that allows numeric values only
A data type for storing lists of named constants
A special kind of array
A structure that can hold any data type
Q134
Q134 How can you instantiate a structure in C?
By using the new keyword
By declaring a variable of the structure type
By defining the structure with #define
By calling a function that returns a structure
Q135
Q135 How are bit fields used in a structure in C?
To define the number of bits used by an integer type member
To encrypt data
To align data in memory
To define array sizes
Q136
Q136 What happens when a structure is passed to a function in C?
The entire structure is copied
Only the structure pointer is passed
The first element is passed
None of the above
Q137
Q137 Complete the C code:
union Data {
int i;
float f;
char str[20];
};
union Data data; ___;
printf("%s", data.str);
to store and print "Hello".
data.str = "Hello";
strcpy(data.str, "Hello");
data = {.str = "Hello"};
data.str = {'H', 'e', 'l', 'l', 'o', '\0'};
Q138
Q138 Identify the error in this C code:
struct Point { int x, y; };
struct Point p1; p1.x = 10; p1.y = 20;
No error
Struct Point not properly declared
Struct members not properly accessed
Struct Point not properly instantiated
Q139
Q139 What is a stream in the context of C programming?
A sequence of characters
A type of data structure
A flow of binary data
A method of structuring code
Q140
Q140 What function in C is typically used to open a file for reading or writing?
fopen()
open()
file_open()
stream()
Q141
Q141 How does file handling in binary mode differ from text mode in C?
Binary mode can read non-text files, text mode cannot
Binary mode is faster
Text mode translates newlines, binary mode does not
Text mode is more secure
Q142
Q142 What happens if you try to write to a file in C without opening it first?
The write operation succeeds with a warning
The write operation fails silently
An error occurs
The file is automatically created
Q143
Q143 What is the purpose of the #include directive in C?
To include a library during program execution
To declare a variable
To include a header file at compile time
To initialize variables
Q144
Q144 How does the #ifndef directive function in C?
It checks if a variable is not defined
It imports a file if not previously imported
It checks if a macro is not defined
It defines a new macro if a condition is met
Q145
Q145 What happens when a header file is included twice in a C program without using include guards?
The program will not compile
The program compiles with warnings
The program compiles successfully, but it may cause errors
Nothing specific
Q146
Q146 Identify the error in this C code snippet:
#include <stdio.h> #define MAX 100 #undef MAX int main() { printf("%d", MAX); return 0; }
Syntax error
Use of undefined MAX
No error
Incorrect usage of printf
Q147
Q147 Spot the mistake:
#ifndef FILE_H #define FILE_H /* File contents */ #endif in a header file named "file.h"
The macro name should match the file name
No error
The header file name should be uppercase
The #ifndef and #define order is incorrect
Q148
Q148 How are command line arguments passed to a C program?
Through global variables
Through function parameters
Through a dedicated command-line function
Through environment variables
Q149
Q149 What is variable argument list in C, and which header file is required for it?
A list of arguments of variable types, stdlib.h required
A list of arguments of fixed types, stdio.h required
A list of arguments of variable length, stdarg.h required
A list of arguments of variable length, string.h required
Q150
Q150 What is the use of the va_start, va_arg, and va_end macros in C?
They are used for file operations
They are used for memory allocation
They are used for handling variable arguments
They are used for error handling


