O Level Internet of Things Paper July 2022 | Set 1
निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code?
int main()
{
int i = 25;
int k =i %4;
printf("%d\n", k);
}
The given code performs a modulo operation (%) on the variable i with 4.
Code explanation:
int i = 25;
int k = i % 4; // Modulo operation
printf("%d\n", k); // Prints the result
The modulo operation returns the remainder when i is divided by 4.
- 25 divided by 4 gives a quotient of 6 with a remainder of 1.
Therefore, i % 4 equals 1.
So, the correct answer is:
(A) 1.
Correct Answer: A) 1
निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code?
void main()
{
int x = 5*6/2 +8;
printf("%d",x);
return 0;
}
Let's break down the code step by step:
Code:
void main()
{
int x = 5*6/2 + 8;
printf("%d", x);
return 0;
}
Step-by-step calculation:
- 5 * 6 gives 30.
- 30 / 2 gives 15.
- 15 + 8 gives 23.
So, the value of x will be 23.
Thus, the output of the program will be:
(C) 23.
Correct Answer: C) 23
निम्नलिखित Arduino कोड का आउटपुट क्या होगा?
What will be the output of the following Arduino code?
#define X 10;
void setup(){
X=0;
Serial.begin(9600);
Serial.print(X);
}
void loop(){
//Do nothing...
}
The given Arduino code contains an issue in the way the macro #define X 10; is defined.
Code Breakdown:
#define X 10;
void setup(){
X = 0; // Trying to assign a value to X
Serial.begin(9600);
Serial.print(X);
}
void loop(){
// Do nothing...
}
Issue:
- The
#definedirective creates a macro replacement, but the semicolon (;) at the end of#define X 10;is incorrect. It will cause the preprocessor to insert a semicolon after the value 10, leading to an issue when trying to assign a value toXin thesetup()function. - You cannot assign a value to
XsinceXis treated as a constant.
Output:
Due to this error in the code, there will be a compilation error.
So, the correct answer is:
(D) Error.
Correct Answer: D) Error
निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code?
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
}
printf("GREEN");
return 0;
}
Let's analyze the given code step by step:
Code:
int main()
{
int a = 5;
while(a = 123) // This is an assignment, not a comparison
{
printf("RABBIT\n");
}
printf("GREEN");
return 0;
}
Key points:
-
while(a = 123)is an assignment operation, not a comparison. The expressiona = 123assigns the value 123 toa, and the result of the assignment is the value assigned (in this case, 123), which is non-zero. In C, any non-zero value is consideredtruein a boolean context. -
Since 123 is non-zero, the while loop will run indefinitely (infinite loop), printing "RABBIT" over and over again.
-
The
printf("GREEN")will never be reached because the program is stuck in the infinite loop inside thewhile.
Output:
The program will print "RABBIT" an unlimited number of times, and the word "GREEN" will never be printed.
So, the correct answer is:
(A) RABBIT is printed unlimited number of times.
Correct Answer: A) RABBIT is printed unlimited number of times
यदि "पिन2" को "1011" भेजा जाता है जहां 1 5V है और 0 0V है तो "पिन1" का आउटपुट क्या है?
What is the output of “pin1” if “pin2” is sent “1011” where 1 is 5V and 0 is 0V?
int pin1 = 12;
int pin2 = 11;
void setup() {
pinMode(pin1, OUTPUT);
pinMode(pin2, INPUT);
Serial.begin(9600);
}
void loop() {
if(digitalRead(pin2)==1) {
digitalWrite(pin1,LOW);
}
else if(digitalRead(pin2)==0) {
digitalWrite(pin1,HIGH);
}
}
The code reads the value on pin2 and sets pin1 based on that:
- If pin2 is HIGH (5V), pin1 is set to LOW (0V).
- If pin2 is LOW (0V), pin1 is set to HIGH (5V).
For the sequence "1011" sent to pin2:
- pin2 = 1 (HIGH) → pin1 = LOW (0V)
- pin2 = 0 (LOW) → pin1 = HIGH (5V)
- pin2 = 1 (HIGH) → pin1 = LOW (0V)
- pin2 = 1 (HIGH) → pin1 = LOW (0V)
Thus, the output of pin1 will be 0100.
The correct answer is:
(B) 0100.
Correct Answer: B) 0100
कोड के निम्नलिखित भाग का आउटपुट क्या होगा?
What will be the output of the following piece of code?
#include <stdio.h>
int main() {
for(i = 0;i < 8; i++);
printf("%d", i);
return 0;
}
Let's break down the given code:
Code:
#include
int main() {
for(i = 0; i < 8; i++);
printf("%d", i);
return 0;
}
Explanation:
-
The
forloop:
Theforloop has a semicolon (;) after it, which means the loop doesn't contain any body (it's an empty loop). It simply incrementsifrom 0 to 7. -
After the loop completes,
iwill be 8, because the loop condition (i < 8) fails whenireaches 8. -
The
printf("%d", i);statement:
This prints the value ofi, which is 8 after the loop terminates.
Output:
So, the output of this code will be:
(C) 8.
Correct Answer: C) 8
फ़ंक्शंस के साथ C प्रोग्राम का आउटपुट क्या है?
What is the output of C program with functions?
int main() {
int a = 0;
printf("AJAY ");
return 1;
printf("VIJAY");
return 1;
}
Let's analyze the given C program:
Code:
int main() {
int a = 0;
printf("AJAY ");
return 1;
printf("VIJAY");
return 1;
}
Explanation:
- The
printf("AJAY ");prints "AJAY ". - The
return 1;statement causes the program to exit themainfunction immediately, returning 1. - Since the program exits at
return 1;, the lineprintf("VIJAY");is never executed.
Output:
The program prints "AJAY " and then exits. The statement to print "VIJAY" is ignored because of the return 1;.
So, the correct answer is:
(B) AJAY.
Correct Answer: B) AJAY
C प्रोग्राम का आउटपुट क्या है?
What is the output of C Program ?
int main()
{
int k=10;
while(k <= 12)
{
printf("%d ", k);
k++;
}
return 0;
}
Let's analyze the given C program step by step:
Code:
int main() {
int k = 10;
while (k <= 12) {
printf("%d ", k);
k++;
}
return 0;
}
Explanation:
- Initialization: The variable
kis initialized to 10. - The
whileloop runs as long ask <= 12. It will print the value ofkand then incrementkafter each iteration. - The loop executes three times with
ktaking values 10, 11, and 12.
Iterations:
- First iteration:
k = 10, it prints "10 ", and thenk++makesk = 11. - Second iteration:
k = 11, it prints "11 ", and thenk++makesk = 12. - Third iteration:
k = 12, it prints "12 ", and thenk++makesk = 13. The conditionk <= 12is no longer true, so the loop stops.
Output:
The program will print: "10 11 12"
So, the correct answer is:
(C) 10 11 12.
Correct Answer: C) 10 11 12
जब a = 4, तो का मान क्या है? नीचे दिए गए कथन में
When a = 4, what is the value of in the given below statement
b = (a > 6 ? 4 : 6);
Let's break down the given statement:
Statement:
b = (a > 6 ? 4 : 6);
This is a ternary operator statement, which works as follows:
-
The ternary operator is in the form:
condition ? value_if_true : value_if_false -
Condition:
(a > 6)
Whena = 4, the condition(a > 6)evaluates to false (since 4 is not greater than 6). -
Result if false: The ternary operator will return the value after the colon (
:), which is 6.
So, b will be assigned the value 6.
Final Answer:
When a = 4, the value of b will be 6.
The correct answer is:
(D) 6.
Correct Answer: D) 6