Professional Documents
Culture Documents
21 qu
1. The different storage classes in C are auto , extern , static , and register .
2. For an auto variable:
◦ Scope: Limited to the block in which it is declared.
◦ Life-time: Exists only within the block and is destroyed when the block is exited.
◦ Location: Stored in the stack memory.
◦ Initial value: Uninitialized and contains garbage data.
3. For an extern variable:
◦ Scope: Can be accessed globally across multiple files or within a specific scope.
◦ Life-time: Exists throughout the program execution.
◦ Location: The actual storage location is determined by the linker.
◦ Initial value: Zero if not explicitly initialized.
4. For a static variable:
◦ Scope: Limited to the block in which it is declared.
◦ Life-time: Exists throughout the program execution.
◦ Location: Stored in the data segment of the memory.
◦ Initial value: Zero if not explicitly initialized.
5. For a register variable:
◦ Scope: Limited to the block in which it is declared.
◦ Life-time: Exists only within the block and is destroyed when the block is exited.
◦ Location: Stored in a CPU register (if available).
◦ Initial value: Uninitialized and contains garbage data.
22-q
pps record 1
1. Command line arguments are parameters passed to a program when it is executed
from the command line.
2. The main() function in C allows two arguments: an integer representing the number
of command line arguments and an array of strings containing the arguments.
3. argc is an integer variable that holds the count of the command line arguments
passed to the program.
4. argv[] or **argv is an array of character pointers (strings) that holds the actual
command line arguments passed to the program.
23-q
pps record 2
24-q
25-q
1. A pointer is a variable that stores the memory address of another variable or object
in a program.
pps record 3
3. Actual parameters, also known as arguments, are the values passed to a function
during a function call. They correspond to the formal parameters in the function
definition.
5. The address of a variable can be obtained using the unary operator "&". For
example, "&variable_name" will give the address of "variable_name".
26-q
1. Dynamic Memory Allocation refers to the process of allocating memory at runtime in
a computer program, allowing the program to request and release memory dynamically
as needed.
2. Static Memory Allocation involves allocating memory at compile-time and the memory
size and location are fixed throughout the program's execution. Dynamic Memory
Allocation, on the other hand, allows memory to be allocated and deallocated during
runtime, enabling flexibility in memory usage.
3. Syntax of malloc(): void* malloc(size_t size);
4. Syntax of calloc(): void* calloc(size_t num, size_t size);
27-q
pps record 4
1. Pointer to an array is a pointer that points to the first element of an array, allowing
operations to be performed on the array through the pointer.
2. Array of pointers is an array where each element of the array is a pointer, pointing to
different memory locations or objects.
3. Null pointer is a pointer that does not point to any memory location or object.
4. Generic pointer, also known as void pointer, is a pointer that can be used to store
the address of any data type.
5. Wild pointer is an uninitialized or invalid pointer that does not point to a valid
memory location, potentially causing unexpected behavior when dereferenced.
28-q
1.
29-q
1. A structure in C is a user-defined data type that allows you to combine different
types of variables under a single name.
pps record 5
3. A nested structure refers to a structure that is a member of another structure.
5. No, it is not necessary that all elements of a structure should be of different size.
Elements of a structure can have the same size or different sizes depending on the
data types used.
30-q
1. The correct syntax to initialize bit-fields in a structure is by using a colon (:) followed
by the number of bits to allocate for the field. For example: struct MyStruct { unsigned
int flag: 1; };
2. Bit-fields can be declared using integer data types such as int, unsigned int, signed
int, char, signed char, unsigned char, short, unsigned short, etc.
31-q
1. A union is a data structure in programming that allows storing different data types in
the same memory location.
2. The memory allocated for a union variable is the size of its largest member.
3. The main difference between a structure and a union is that a structure allows
storing multiple members of different data types, each occupying separate memory
locations, while a union allows storing only one member at a time, sharing the same
memory location.
pps record 6
4. The advantages of using a union include saving memory by sharing memory space
among different data types and providing a convenient way to interpret the same
memory location as different types of data.
5. A drawback of unions is that they can lead to potential data type and memory
access issues if not used carefully, as accessing one member may inadvertently
access or modify other members.
32-q
1. An enum is a data type in programming that represents a set of named values, also
known as enumerators or constants.
3. Enum permits integer constants, where each constant represents a distinct value
within the enumeration.
4. The beginning value of the enum constant is typically 0, but it can be explicitly
assigned a different value if desired.
5. Yes, enum allows defining user-defined constants by assigning explicit values to the
enumerators.
33-q
pps record 7
1. A FILE is a data structure used in programming to represent a file stream, which
provides a way to interact with files in input/output operations.
2. The types of files can include text files, binary files, input/output device files, and
special files (such as directories or sockets).
3. File modes determine the operations that can be performed on a file, including read,
write, append, and create modes.
4. Different functions used to write to a file include fwrite(), fprintf(), fputs(), and putc().
5. Different functions used to read from a file include fread(), fscanf(), fgets(), and getc().
34-q
1. Random Access to Files refers to the ability to directly access or manipulate data
within a file in a non-sequential manner, allowing reading or writing at any specific
position.
2. The fseek() function parameters include the file pointer, offset (number of bytes to
move), and origin (starting position from where the offset is applied).
3. The ftell() function returns the current position indicator (number of bytes from the
beginning of the file) associated with the file pointer.
4. rewind() is a function that resets the position indicator of a file to the beginning,
equivalent to fseek(file_pointer, 0, SEEK_SET).
5. exit(0) is a function call that terminates the program execution and returns an exit
status of 0, indicating successful execution.
pps record 8