Section A
attempt all questions in brief.
a. 1Nibble =………..Bytes.
Answer:
1 Nibble = 0.5 Bytes
Explanation: 1 Nibble = 4 bits; 1 Byte = 8 bits → 4/8 = 0.5 Bytes
b. Find the value of variable max in the following code: -
int a=10, b=20; int max= (a>b)? a: b;
Answer:
max = 20
Explanation: Since
a = 10
and b = 20
, the condition (a > b)
is false. So the ternary operator returns b
.
c. Define Explicit type conversion with suitable example.
Answer:
Explicit type conversion, also known as type casting, is when a programmer manually converts one data type into another.
Example:
float x = 5.75;
int y = (int)x; // Explicitly converting float to int
(int)x
converts 5.75
to 5
by truncating the decimal part.d. Write a C program to print all natural numbers from 10 to 100.
Answer:
#include <stdio.h>
int main() {
int i;
for(i = 10; i <= 100; i++) {
printf("%d ", i);
}
return 0;
}
for
loop to print natural numbers from 10 to 100.e. Define Pointer to Pointer.
Answer:
A Pointer to Pointer is a variable that stores the address of another pointer.
Syntax Example:
int a = 5;
int *p = &a;
int **pp = &p;
pp
is a pointer to the pointer p
, which in turn points to variable a
.f. Find the output of following code: -
#include<stdio.h>
#defien a 2*2+2
void main () {
int b,c; b=2/a;
c=b+4;
printf(“Value of variable b and c are %d%d respectively ”, b,c);
}
Answer:
There are two issues:
-
Typo:
#defien
should be#define
. -
Macro expansion issue due to missing parentheses.
Corrected Code:
g. Draw block diagram to represent doubly linked list.
Answer:
Each node in a doubly linked list contains:
-
A pointer to the previous node
-
The data
-
A pointer to the next node
Explanation:
-
The first node’s
prev
points toNULL
. -
The last node’s
next
points toNULL
. -
Every node is bidirectionally linked.