You are on page 1of 8

pps record

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.

5. atoi() is a function in C that converts a string representation of an integer to its


corresponding integer value.

23-q

1. #define is a preprocessor directive in C that is used to define a constant or a macro.


2. The purpose of the Stringizing operator (#) in C is to convert a macro parameter or
token into a string literal.
3. A macro in C is a symbolic name or identifier that is defined using the #define
directive. It is used to represent a piece of code or a constant value that can be reused
throughout the program.
4. The main difference between a macro and a function in C is that a macro is a textual
substitution performed by the preprocessor before compilation, whereas a function is a
reusable block of code that is executed during runtime.
5. A parameterized macro is a macro that accepts parameters. It allows the substitution
of values or expressions in the macro definition and provides flexibility in code
generation.

pps record 2
24-q

1. Conditional compilation is a feature in C that allows parts of the code to be


selectively included or excluded during the compilation process based on certain
conditions or preprocessor directives.

2. #ifdef is a preprocessor directive in C that checks if a certain macro or identifier has


been defined using #define. If the macro is defined, the code block following #ifdef
is included during compilation.

3. #ifndef is a preprocessor directive in C that checks if a certain macro or identifier


has not been defined using #define. If the macro is not defined, the code block
following #ifndef is included during compilation.

4. #if is a preprocessor directive in C that allows conditional compilation based on


constant expressions evaluated at compile-time. It checks if a given expression
evaluates to true, and if so, includes the subsequent code block during compilation.

5. #endif is a preprocessor directive in C that marks the end of a conditional


compilation block started by directives like #ifdef, #ifndef, or #if. It indicates the end
of the code block that should be included or excluded based on the preceding
condition.

25-q
1. A pointer is a variable that stores the memory address of another variable or object
in a program.

2. In call-by-value, a copy of the value is passed to a function, so any changes made


to the parameter inside the function do not affect the original value. In call-by-
reference, the memory address of the parameter is passed, allowing changes made
inside the function to affect the original value.

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.

4. Formal parameters, also known as parameters or arguments, are variables or


placeholders specified in a function definition. They represent the values that are
expected to be passed to the function when it is called.

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

5. Syntax of realloc(): void* realloc(void* ptr, 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.

a. Function pointer is a pointer that points to a function, allowing the program to


call that function indirectly through the pointer.

2. Pointer returns a function refers to a pointer that is capable of returning a function,


whereas a function pointer is a pointer that points to a function. The former allows
the returned function to be assigned to another function pointer, while the latter
directly points to a specific function.

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.

2. The keyword used to define a structure in C is "struct".

pps record 5
3. A nested structure refers to a structure that is a member of another structure.

4. No, we cannot declare a function inside a structure in C programming. Functions


are declared separately and can be associated with structures using function
pointers.

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.

2. Typedef is a keyword in programming used to create an alias or a new name for an


existing data type.

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

You might also like