Week 8
Week 8
C Programming
Q1) A stack is a data structure that follows the LIFO (Last In, First Out) principle. It means the
last element added to the stack will be the first one to be removed. Operations typically
performed on a stack include:
return 0;
}
Q3) The ldexp() function in C is used to calculate the result of multiplying a floating-point
number by 2 raised to the power of a given integer. Its prototype is:
double ldexp(double x, int exp);
Q4) Use the frexp() function, which decomposes a floating-point number into its mantissa
and exponent. The prototype is:
double frexp(double x, int *exp);
Q5) Use the atexit() function to register a function that is called when the program
terminates normally. Example:
#include <stdio.h>
#include <stdlib.h>
void cleanup() {
printf("Program is terminating. Cleanup function executed.\n");
}
int main() {
atexit(cleanup); // Register the cleanup function
printf("Program is running.\n");
return 0;
}
C++ Programming
● Reason:
Static functions are not tied to any specific instance of a class and do not operate on
instance data (i.e., this pointer is not available in static functions).
Virtual functions, on the other hand, rely on the this pointer and polymorphism, which is
dependent on an object instance. Hence, these two concepts are fundamentally
incompatible.
Q2) The confusion arises from the term const in const char *p.
Here, const char *p means that the data being pointed to by p cannot be modified, but the
pointer p itself can be reassigned to point to another memory location.
In the program, p is declared but not initialized initially. Later, it is assigned the address of the
string literal "A const pointer". This assignment is valid because the const qualifier
applies to the data pointed to by p, not the pointer p itself.
Data Structure
Q1) The most suitable data structure for efficient tree construction is the Binary Search Tree
(BST) or specialized versions like AVL Trees or Red-Black Trees.
Unix
Q2) Get an environment variable: Use getenv() from the stdlib.h library.
Q1) A join operation in DBMS combines rows from two or more tables
based on a related column. Types of joins include:
Operating System
SQL
Action:
WHERE Clause:
Trigger Execution:
Rollback:
Speed:
Q3)1) SELECT *
FROM SOFTWARE
FROM STUDIES
Computer Networks
Layer:
Terminal emulation operates in the Application Layer of the OSI (Open
Systems Interconnection) model. This layer provides the interface
between the user and the network, facilitating services like file
transfers, email, and remote login.