1.
SFRs are used for:
Correct Answer
D. Configuring peripHerals
Explanation
SFRs, or Special Function Registers, are used for configuring peripherals. These registers are specific to a microcontroller and are used to control and interact with various hardware peripherals such as timers, UART, ADC, GPIO, etc. They provide a way to configure and control the behavior of these peripherals by writing or reading specific values to/from these registers. Therefore, the correct answer is "Configuring peripherals".
2.
To flash an LED @ 5Hz, the ON/OFF time (in ms) for the LED shall be
Correct Answer
D. 100/100
Explanation
To flash an LED at 5Hz, the LED needs to turn on and off 5 times per second. This means that the LED should have a cycle time of 1/5 seconds or 200ms. Since the LED needs to be on for half of the cycle and off for the other half, the ON/OFF time for the LED should be equal, which is 100ms. Therefore, the correct answer is 100/100.
3.
We want to round off x, afloat, to an int value, The correct way to do is
Correct Answer
A. Y = (int)(x + 0.5)
Explanation
To round off a float value x to an int value, the correct way is to add 0.5 to x and then cast the result to an int. This is done in the expression y = (int)(x + 0.5). By adding 0.5, we ensure that the decimal part of x is properly accounted for in the rounding process. Casting the result to an int truncates the decimal part, giving us the rounded off int value.
4.
The following program fragment
char xyz[3][4] = {“bag”, “set”, “hat”};
char (*ptr)[4] = xyz;
putchar(* (xyz[1] + 1));
Correct Answer
D. Prints e
Explanation
The program fragment initializes a 2-dimensional character array called xyz with three strings: "bag", "set", and "hat". It then declares a pointer to an array of 4 characters called ptr and assigns it the address of the first element of xyz. The expression *(xyz[1] + 1) is equivalent to *(ptr + 1), which accesses the second character of the second string in xyz, which is 'e'. Therefore, the program prints 'e'.
5.
Which of the following data structure can be used to search an element in constant time?
Correct Answer
B. Hash Table
Explanation
A hash table can be used to search an element in constant time because it uses a hash function to map the element's key to its corresponding index in the table. This allows for direct access to the element, making the search operation efficient. In a properly implemented hash table, the time complexity for searching an element is O(1), regardless of the size of the data structure.
6.
If the machine in which the following program is executed is little-endian
void main()
{
int y=0x12530001;
printf("%X", (*(char *)&y));
}
the output will be
Correct Answer
A. 01
Explanation
The program is using a pointer to access the memory address of the integer variable 'y' as a character pointer. Since the machine is little-endian, the least significant byte of the integer 'y' (0x01) will be printed first. Therefore, the output will be '01'.
7.
The output of the following section of code is:
unsigned int x = ~((unsigned int)0xc5);
printf(“0x%x”, x);
Correct Answer
B. 0xff3a
Explanation
The code starts by assigning the bitwise complement of the hexadecimal value 0xc5 to the unsigned int variable x. This means that all bits in the hexadecimal value are flipped. Then, the printf statement prints the value of x in hexadecimal format. The correct answer, 0xff3a, is the hexadecimal representation of the bitwise complement of 0xc5.
8.
If n has the value 3, then the statement
a[++n] = n++ ;
Correct Answer
C. Assigns 4 to a[4]
Explanation
The given statement assigns the value of n (which is 3) to a[4]. The prefix increment operator (++n) increments the value of n by 1 before it is assigned to a[4]. The postfix increment operator (n++) increments the value of n by 1 after it is assigned to a[4]. Therefore, the value of n becomes 4 and it is assigned to a[4].
9.
In an architecture with an int type equal to 2 bytes, the output of the following piece of code is
unsigned int *x;
printf(“%x,”, x);
*x = 5;
x++;
printf(“%x”, x);
Correct Answer
B. Bff5a400,bff5a402
Explanation
The code declares a pointer variable `x` of type `unsigned int`. Since the architecture has an `int` type equal to 2 bytes, the size of `unsigned int` is also 2 bytes.
In the first `printf` statement, the address of `x` is printed using `%x` format specifier. This will print the hexadecimal representation of the memory address of `x`, which is `bff5a400`.
Then, `*x = 5` assigns the value 5 to the memory location pointed to by `x`.
After that, `x++` increments the value of `x` by the size of `unsigned int`, which is 2 bytes. So, the new address pointed to by `x` is `bff5a402`.
In the second `printf` statement, the new address of `x` is printed, which is `bff5a402`.
10.
What will be the output of the following:
int a = 1;
while(a)
{
printf("value of a: %d", a--);
}
do {
printf("value of a: %d\n", a--);
}while(a);
Correct Answer
C. Value of a: 1
value of a: 0
Explanation
The output of the code will be "value of a: 1" and "value of a: 0".
In the first part of the code, the while loop will execute as long as the condition "a" is true. Since "a" is initially set to 1, the loop will execute once and print "value of a: 1". Then, the value of "a" is decremented by 1.
In the second part of the code, the do-while loop will execute at least once before checking the condition. Since "a" is now 0, the loop will execute once and print "value of a: 0". Then, the value of "a" is decremented by 1 again. Since "a" is now -1, the condition of the do-while loop is false and the loop terminates.
11.
If the frequency is reduced by half, the dynamic power will
Correct Answer
C. Reduce to half
Explanation
When the frequency is reduced by half, the dynamic power will also reduce by half. This is because dynamic power is directly proportional to the frequency. As the frequency decreases, the number of clock cycles per second decreases, resulting in a decrease in the power consumed by the circuit. Therefore, the dynamic power will reduce to half when the frequency is reduced by half.
12.
:The collector-base junction in a transistor has:
Correct Answer
B. Reverse bias at all times
Explanation
The collector-base junction in a transistor is always reverse biased. This means that the collector terminal is at a higher voltage than the base terminal. Reverse biasing helps to control the flow of current in the transistor. It creates a depletion region at the junction, preventing the flow of majority carriers (electrons in an NPN transistor). This allows the transistor to operate in its active region, where it can amplify and control currents effectively. Forward biasing the collector-base junction would lead to excessive current flow and potentially damage the transistor.
13.
In the diagram shown below if Vin = 10V, what will be the voltage across resistor Vout after an infinite time?
Correct Answer
C. 0V
Explanation
The voltage across resistor Vout will be 0V after an infinite time because the circuit shown in the diagram is a voltage divider circuit. In a voltage divider circuit, the voltage across the resistor is determined by the ratio of the resistance of the resistor to the total resistance in the circuit. In this case, the resistor Vout is connected in parallel with a short circuit, which means that the total resistance in the circuit is effectively 0Ω. Therefore, the voltage across the resistor Vout will be 0V.
14.
To tune a parallel resonant circuit to a higher frequency, the capacitance should be
Correct Answer
C. Decreased
Explanation
To tune a parallel resonant circuit to a higher frequency, the capacitance should be decreased. This is because in a parallel resonant circuit, the frequency of resonance is determined by the product of the inductance and capacitance. By decreasing the capacitance, the resonant frequency will increase. This can be achieved by either reducing the value of the capacitance or by replacing the capacitor with a lower value capacitor.
15.
When the frequency of the voltage applied to a series RC circuit is decreased, the impedance:
Correct Answer
A. Increases
Explanation
When the frequency of the voltage applied to a series RC circuit is decreased, the impedance increases. This is because the impedance of a series RC circuit is inversely proportional to the frequency. As the frequency decreases, the impedance increases, and vice versa.