Schedule‎ > ‎

### Quiz2 Prep

 Quiz 2 Prep (Quiz will be given Wed. 2/15/2017):  Lecture Notes:  02B, 03A, 03B, 04A The quiz questions will be a lot like these: 1.      The value of x after the following code executes is ________. int x = 6; if (x == 3) {   x = 1; } 2.      The value of x after the following code executes is ________. int x = 3; int y = 4; if (x != y) {   x = y; } 3.       Write nested if/else code to do the following:  You get a guess from your user.  If guess < 10 print “your guess is too low”.  If guess > 10 print “your guess is too high”. If guess is 10 print “Correct!!!”. 4.       What’s the purpose of the following code?  Will the Serial.read(); statement always execute at least 1 time?                while (Serial.available())  {                       Serial.read();                 } 5.       Write an example of an integer:          a float/double:              a literal: 6.       What is the purpose of the INPUT_PULLUP setting on a pin? 7.       Calculate the voltage if your analogRead result is 511    Answer:  2.5v 8.       Calculate the Current (amps) if the voltage is 5v and the Resistance is 220ohms. Ans: .0227amps 9.   If my resistor is yellow-purple-orange  what is it’s ohm value?   Ans. 47000 ohm 11.   If I have a 10,000 ohm resistor – what 3 color bands does it have?  Brown-black-orange 12.   What is the resistance for Resistors in Series?  R1 = 220ohms and R2 = 1000ohm Ans.1220ohms 13.   What is the resistance for Resistors in Parallel?   R1 = R2 = 560ohm Ans. 280ohm 14.   What is a Potentiometer? 15.   What is a Voltage Divider used for? 16.   In a Voltage Divider:  if Vin = 5v and R1 = 1000ohms and R2 = 220ohms what is Vout? Ans. 0.92v 17.   What is the result of 5/4? 18.   What is the result of 5.0/4 19.   What is the result of 5%4? 20.  Which of the following correctly declares a variable for a single character and assigns it a value? a.       char var = 'z'; b.      char var = 122; c.       char var = "z"; d.      char var = 'a' + 25; 21.  Which of the following is the correct way to declare a string variable named myString and assign it the text "Hi Mom!"? a.  string myString = Hi Mom!; b.  string myString = "Hi Mom!"; c.  String myString = "Hi Mom!"; d.  String myString = "Hi Mom"! 22.   Which of the following is a correct way to print: Say, "Hey"!? a.  Serial.println("Say, "Hey!""); b.  Serial.println(\"Say, "Hey!"\"); c.  Serial.println("Say, \"Hey!\""); d.  Serial.println("Say, \"Hey!"\");