Internet of Things and its Applications

Building IoT Applications - Set 3

  1. What will be the output of the following code?
     int main() 
     { 
     int i = 25; 
     int k =i %4; 
     printf("%d\n", k); 
     }
    
    1. 1
    2. 0
    3. 2
    4. 4
    Answer : A
    Explain : Here k=i%4 = 25%4 = 1(remainder).
  2. Which command is the 9th pin on Arduino set as output ?
    1. int sensorPin = 9;
    2. int sensorValue = 9;
    3. pinMode(9, OUTPUT);
    4. digitalWrite(9, HIGH);
    Answer : C
    Explain : pinMode(9,OUTPUT) - means that the pin number 9 is used for output. For input we use pinMode(9,INPUT)
  3. What will be the output of the following code ?
     
     void main() 
     { 
     int x = 5*6/2 +8; 
     printf("%d",x); 
     return 0; 
     } 
    
    1. 20
    2. 21
    3. 23
    4. 19
    Answer : C
    Explain : x=5*6/2 + 8 = 30/2+8 = 15+8 =23.
  4. Which of the Arduino pins is connected to the Data5 (D5) pin on the 16x2 character LCD ?
    Liquid Crystal lcd(12, 11, 5, 4, 3, 2);
    1. Pin No. 3
    2. Pin No. 2
    3. Pin No. 5
    4. Pin No. 4
    Answer : D
    Explain :
  5. 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…
     }
    
    1. 0xAB
    2. 0xab
    3. 0
    4. Error
    Answer : D
    Explain :
  6. What will be the output of the following code ?
     
     int main() 
     { 
     int a=5; 
     while(a=123) 
     { 
     printf("RABBIT\n"); 
     } 
     printf("GREEN"); 
     return 0; 
     }
    
    1. RABBIT is printed unlimited number of times
    2. RABBIT GREEN
    3. Compiler error
    4. GREEN
    Answer : A
    Explain : While loop is run unlimited time because the value of a does not change it is remain 123 and the while loop remain true. Then it print RABBIT unlimited time.
  7. 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); 
     } 
     }
    
    1. 1110
    2. 0100
    3. 1111
    4. 1011
    Answer : B
    Explain : The given Arduino code sets up two pins: "pin1" as an OUTPUT and "pin2" as an INPUT. The code continuously reads the state of pin2 and sets the state of pin1 accordingly.
    If "pin2" is sent "1011" where 1 represents 5V and 0 represents 0V.
    When "pin2" receives 1 (5V), "pin1" will be set to 0V - 0.
    When "pin2" receives 0 (0V), "pin1" will be set to 5V- 1.
    When "pin2" receives 1 (5V), "pin1" will be set to 0V- 0.
    When "pin2" receives 1 (5V), "pin1" will be set to 0V - 0.
  8. 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; 
     }
    
    1. 0
    2. 12345678
    3. 8
    4. infinite loop
    Answer : C
    Explain : The loop will execute 8 times, incrementing i from 0 to 7. After the loop, the value of i (which is now 8) will be printed.
  9. In C, how do you set up an array?
    1. int k={3,4}
    2. int k=new int[2]
    3. int k [2] ={3,4};
    4. int k(2)={3,4};
    Answer : C
    Explain : To setup array :- data_type array_name[array_size];. Example int myArray[5] = {10, 20, 30, 40, 50};
  10. What is the output of C program with functions ?
     
     int main() { 
     int a = 0; 
     printf("AJAY "); 
     return 1; 
     printf("VIJAY"); 
     return 1; 
     }
    
    1. AJAY VIJAY
    2. AJAY
    3. VIJAY
    4. Compiler error
    Answer : B
    Explain : In the program, there are two return statements in the main function. However, the second return statement and the code that follows it will never be executed, because the return 1 stop it and exit from the function.
  11. int a:16; what is 16 indicate here ?
    1. Value
    2. Size
    3. Address
    4. None of these
    Answer : B
    Explain : The int a:16; statement declares an integer variable a that uses 16 bits to store its value.The 16 indicates that the variable a will use 16 bits (2 bytes) of storage for its value.
  12. What is switching time for relay to operate with Arduino?
    1. 5-10 s
    2. 5-10 ms
    3. 10-15 ms
    4. 10-12 ms
    Answer : B
    Explain :
  13. Arduino uno have ___size of program memory.
    1. 10 KB
    2. 4KB
    3. 64KB
    4. 32KB
    Answer : D
    Explain : The Arduino Uno, which is based on the ATmega328P microcontroller, has 32KB of Flash memory for storing the program code. This Flash memory is where your Arduino sketches (programs) are stored and executed from.
  14. Clock Speed of Arduino UNO is :
    1. 16 MHz
    2. 12 MHz
    3. 18 MHz
    4. 14 MHz
    Answer : A
    Explain : Arduino Uno, typically operates with a clock speed of 16 megahertz (MHz). This clock speed determines the speed at which the microcontroller executes instructions and processes data.
  15. What is the output of C Program ?
     int main() 
     { 
     int k=10; 
     while(k <= 12) 
     { 
     printf("%d ", k); 
     k++; 
     } 
     return 0; 
     }
    
    1. 10 10 10
    2. 10 11 12
    3. 11 11 11
    4. 12 12 12
    Answer : B
    Explain : while loop that prints the value of k while k is less than or equal to 12, and then increments k by 1 in each iteration.So value of k is 10 and then increment k+1=11, print. So result is 10 11 12.

Next Set

1 2