Menu

(Solved) : 9 One Major Differences C C Python Use Curly Braces Character C C Open Curly Brace Must Fo Q44105067 . . .

9. One of the major differences between C/C++ and Python is in the use of curly braces and the character. In C/C++, an open c

There are other ways to fix this problem (some easier, some harder). Select the correct answer from the choices below: a. Don

THE TOPIC IS :

ENGR 217/PHYS 217 Experimental Physics and Engineering Lab III - Electricity and Magnetism Credits 2. 1 Lecture Hour. 3 Lab H

9. One of the major differences between C/C++ and Python is in the use of curly braces and the character. In C/C++, an open curly brace must be followed by a closed curly brace, and <the blank you filled in is for readability only> is optional but is generally used for readability. In python, you must use <the blank you filled in> to indicate groupings. a port once before using (read from or write to it in the 10. You must setup function. 11. T or F: analogWrite function uses a D to A converter to output an analog voltage between 0 and 5.0 volts. 12. T or F: Essentially all modern fuel injected gasoline engines use PWM to control how much fuel is sprayed into the intake plenum or directly into the combustion chambers. 13. In C/C++ all lines of code that don’t start or end with a curly brace are terminated by 14. T/F: Serial.print() function allows the user to print data to PC or mac via USB cable. 15. In class, we showed the following code has an unintended bug due to the likelihood of an overflow condition in the variable “counter.” We also showed an easy fix (move the increment of the counter inside the conditional). // Simple illustration of variable overflow unsigned int counter = 0; void setup 0 { Serial.begin (9600); delay(500); void loop( { if (counter < 10) { Serial.println (counter); counter++; // Same as counter=counter+1; There are other ways to fix this problem (some easier, some harder). Select the correct answer from the choices below: a. Don’t let it roll over: Add a conditional so that when the number stored in the variable becomes the largest value that can be stored (65,535 in this case), reset the number to 10 and let it count again. b. Move this initial task where it should be: We desire to display the numbers 0- 9 once. This is essentially a setup operation and makes no sense to perform within an infinite loop. Move this task to the setup() function where it will be done once (using a for loop) and then be done with it. c. Detect and correct: Re-design your code so if the variable rolls over, you detect that it did so and correct the problem. For example, an int (as opposed to an unsigned int) can have either positive or negative values. Your expected difference between two successive values from a counter that is increasing monotonically should always be positive. If you get a negative difference, you know the counter rolled over. You fix that problem. d. a, b, and c e. a and b 16. A suggestion your instructor found on the Internet (so it must be true) suggests one can solve overflow problem by declaring a variable as a long unsigned int. This declaration uses two 16-bit words to store a variable. The maximum value of an unsigned long int is 232. 1 = 4,294,967,295 as opposed to 65,535 for an unsigned 16-bit int. Let’s assume you are storing using the results from the millis() time function (this is a form of a counter). T/F: This is an effective solution to the overflow problem. (Hint: Calculate many days the maximum number of milliseconds you can store in an unsigned long int is and then compare length of time to how long you expect a machine you design would operate on a continuous basis.) ENGR 217/PHYS 217 Experimental Physics and Engineering Lab III – Electricity and Magnetism Credits 2. 1 Lecture Hour. 3 Lab Hours. Electromagnetism and electromechanical systems; use of sensing, control and actuation to demonstrate key physical relationships through the transducer relationships linking pressure, temperature and other physical stimuli to changes in electric and magnetic fields. Prerequisites: Grade of C or better in MATH 152 or MATH 172, or equivalent; grade of C or better in PHYS 206 or equivalent; grade of C or better in PHYS 216/ENGR 216 or ENGR 216/PHYS 216; grade of C or better and concurrent enrollment in PHYS 207; also taught at Galveston campus. Cross Listing: PHYS 217/ENGR 217. Show transcribed image text 9. One of the major differences between C/C++ and Python is in the use of curly braces and the character. In C/C++, an open curly brace must be followed by a closed curly brace, and is optional but is generally used for readability. In python, you must use to indicate groupings. a port once before using (read from or write to it in the 10. You must setup function. 11. T or F: analogWrite function uses a D to A converter to output an analog voltage between 0 and 5.0 volts. 12. T or F: Essentially all modern fuel injected gasoline engines use PWM to control how much fuel is sprayed into the intake plenum or directly into the combustion chambers. 13. In C/C++ all lines of code that don’t start or end with a curly brace are terminated by 14. T/F: Serial.print() function allows the user to print data to PC or mac via USB cable. 15. In class, we showed the following code has an unintended bug due to the likelihood of an overflow condition in the variable “counter.” We also showed an easy fix (move the increment of the counter inside the conditional). // Simple illustration of variable overflow unsigned int counter = 0; void setup 0 { Serial.begin (9600); delay(500); void loop( { if (counter

Expert Answer


Answer to 9. One of the major differences between C/C++ and Python is in the use of curly braces and the character. In C/C++, an o…

OR