O Level Internet of Things Paper January 2023
निम्नलिखित अरुडिनो कोड का परिणाम क्या है?
What is the outcome of the following Arduino code ?
void setup() {
Serial.begin(9600);
}
void setup() {
Serial.write(20);
}
Let's analyze the provided Arduino code:
Code:
void setup() {
Serial.begin(9600);
}
void setup() {
Serial.write(20);
}
Explanation:
-
Serial.begin(9600);:- This initializes serial communication at a baud rate of 9600 bits per second. It prepares the Arduino to send and receive data over the serial connection.
-
Serial.write(20);:Serial.write()sends data as bytes over the serial connection. It takes a single byte as an argument and sends it.- The argument
20is a decimal value, which is equivalent to 0x14 in hexadecimal and 24 in binary. - The
write()function sends this byte (value 20) to the serial port.
Outcome:
- The code will send a byte with the value 20 (in decimal) through the serial connection.
- This is not a string or number in octal/hexadecimal format, but the actual byte value 20.
Correct Answer:
(C) Send a byte with value 20 through the Serial pins.
Correct Answer: C) Send a byte with value 20 through the Serial pins
निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code ?
#include <stdio.h>
void solve() {
char ch[5] = "abcde";
int ans = 0;
for(int i = 0; i< 5; i++) {
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main() {
solve();
return 0;
}
Code Breakdown:
-
Character Array: The array
ch[5]is initialized with the string"abcde", which meansch[0] = 'a',ch[1] = 'b', and so on. -
Loop & Calculation: The program loops through each character, subtracts the ASCII value of
'a'(which is 97) from each character, and adds the result toans.'a'→97 - 97 = 0'b'→98 - 97 = 1'c'→99 - 97 = 2'd'→100 - 97 = 3'e'→101 - 97 = 4
-
Summing Up: The final sum of
ansis0 + 1 + 2 + 3 + 4 = 10.
Output:
The output will be 10.
Correct Answer:
(D) 10.
Correct Answer: D) 10
यदि निम्नलिखित कोड के आक्षेपों की भविष्यवाणी करें वस्तु संवेदक से दूर जा रही है:
Predict the output of the following code if the object is moving away from the sensor :
int op = 7;
int isBarrier = HIGH;
void setup() {
pinMode(op, INPUT);
Serial.begin(9600);
}
void loop() {
isBarrier = digitalRead(op);
if (isBarrier == LOW) {
Serial.println("1+");
}
else {
Serial.print("clear+");
}
delay(100);
}
निम्नलिखित अरुडिनो कोड का आउटपुट क्या होगा?
What will be the output of the following Arduino code ?
void main() {
int k = 0;
double d = 10.21;
printf(“%lu”, sizeof(k + d));
}
void loop() {}
The code calculates the size of the result of k + d, where k is an integer and d is a double. Since adding an integer and a double promotes the result to a double, the size of the result (k + d) is 8 bytes (the size of a double on most Arduino boards). Therefore, the output is 8.
Correct answer: (B) 8.
Correct Answer: B) 8
निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code ?
#include <stdio.h>
void solve() {
int b = 4;
int res = b++ + ++b + ++b;
printf("%d", res);
}
int main() {
solve();
return 0;
}
The code calculates the result of the expression b++ + ++b + ++b, where b starts at 4:
b++uses the value 4, then incrementsbto 5.++bincrementsbto 6 and uses that value.++bincrementsbto 7 and uses that value.
The sum is 4 + 6 + 7 = 17.
Output: (C) 17.
Correct Answer: C) 17
निम्नलिखित कार्यक्रम का आउटपुट क्या है?
What is the output of the following program ?
for( ; ; )
{
Statements
}
The given for loop has no condition, so it runs indefinitely. This creates an infinite loop, where the statements inside the loop will execute forever.
Output: (D) Both (B) and (C).
Correct Answer: D) Both (B) and (C)
नीचे दिए गए कोड का उद्देश्य क्या है यदि इसे Arduino Uno पर निष्पादित किया जाता है?
What is the objective of the code given below if it is executed on the Arduino Uno ?
#include<EEPROM.h>
int pin=13;
void setup() {
pinMode(pin,OUTPUT);
Serial.begin(9600);
}
void loop() {
for(int i=0; i<EEPROM.length(); i++) {
EEPROM.write(i, 1);
}
digitalWrite(pin,HIGH);
exit(0);
}
The code writes 1 to every byte in the EEPROM memory of the Arduino Uno, effectively filling the EEPROM with 1s. It then turns on the onboard LED (pin 13) and exits.
Objective: (B) Fill EEPROM with 1's.
Correct Answer: B) Fill EEPROM with 1's
यदि वस्तु सेंसर की ओर बढ़ रही है निम्नलिखित कोड के आउटपुट की भविष्यवाणी करें।
Predict the output of the following code if the object is moving towards the sensor.
int op = 6;
int isBarrier = HIGH;
void setup() {
pinMode(op, INPUT);
Serial.begin(9600);
}
void loop() {
isBarrier = digitalRead(op);
if (isBarrier == LOW) {
Serial.println("1+");
}
else {
Serial.print("clear+");
}
delay(100);
}
As the object moves towards the sensor, it will block it, causing the sensor to read LOW, which prints 1+. If the object moves away, it will read HIGH, printing clear+.
Output: (A) clear+clear+1+1.
Correct Answer: B) 1+1+clear+1