Week 7_Assignment
Week 7_Assignment
C Programming
1. If we have declared an array as global in one file and we are using it in another file then why
doesn't the sizeof operator works on an extern array?
Ans: When you declare an array as extern in a file, you're only declaring a reference to the array, not
defining it. The compiler has no information about its size at the point of the sizeof operation. The sizeof
operator only works with the actual definition of an array because it needs the size at compile time..
2. How do I write printf() so that the width of a field can be specified at runtime?
Ans: You can use the * specifier in printf() to specify the field width dynamically at runtime.
Example:
#include <stdio.h>
int main() {
return 0;
3. How to find the row and column dimension of a given 2-D array?
Ans: The dimensions of a 2-D array can only be determined if you have access to its declaration. You
cannot determine them at runtime using the array pointer because it decays to a pointer when passed to a
function.
Example:
#include <stdio.h>
#define ROWS 3
#define COLS 4
int main() {
int arr[ROWS][COLS];
printDimensions(arr);
return 0;
Ans: The access() function is used to check the accessibility of a file. It is defined in <unistd.h>.
Example:
#include <stdio.h>
#include <unistd.h>
int main() {
{ printf("File exists.\n");
if (access(filename, R_OK) == 0)
printf("File is readable.\n");
else
if (access(filename, W_OK) == 0)
printf("File is writable.\n");
else
} else {
return 0;
Ans: You can use sprintf() or functions like gcvt() or snprintf() to convert a float to a string.
Example using sprintf():
#include <stdio.h>
int main() {
char str[20];
return 0;
C++ Programming
Answer: Output:
a = 10, pa = 10, ra = 10
Answer:
The loop iterates 3 times, and each iteration calls deri::out(). Therefore, the output is:
- deri deri deri
Technical Questions
Data Structures
B-Trees: Used in file systems and databases for organizing large blocks of data.
Unix
Ans: A system call is a mechanism used by a program to request services from the operating system's
kernel.
Hello World
DBMS
1: What is Tuple?
Ans: A tuple is a single row of data in a table, representing a single record.
2:What is a Selection?
Ans: Selection is a relational algebra operation used to filter rows in a table based on a specified condition.
1:What is Arm-Stickiness
Ans: Arm-stickiness refers to a situation in disk scheduling algorithms like SCAN or LOOK where the
disk arm tends to "stick" or stay on one side of the disk, repeatedly servicing requests in a certain region
due to constant new requests in that area
● Discretionary Access Control (DAC): Ensuring authorized users have appropriate access.
● Auditing: Tracking all attempts to access the system.
● Object Reuse Protection: Preventing unauthorized access to deleted data.
● Identification and Authentication: Ensuring secure login mechanisms.
SQL
● Removes all rows from the table without logging individual row deletions.
● Faster and does not allow rollback.
To count the number of programmers who have done the DCA course, we join the STUDIES table with the PROGRAMMER table on the common
field PNAME, and filter for the COURSE column with the value 'DCA':
SQL Query:
FROM STUDIES S
2. How much revenue has been earned through the sale of packages developed in C?
To calculate the revenue earned, we filter the SOFTWARE table for the DEVIN field with the value 'C', and multiply the SCOST (software cost) by
the SOLD (number of units sold):
SQL Query:
FROM SOFTWARE
Computer Networks
● Frame Relay primarily operates at the Data Link Layer (Layer 2) of the OSI model.
Key Features:
Leetcode Questions