Given the C program in Figure 1, find the output of the program main.c 1 #include...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the C program in Figure 1, find the output of the program main.c 1 #include 2 3 void convert(int); 4 int convert2(int); 5 6 int main(void) { 7 int a=5; 8 10 11 12 13 14 15 int b; printf("Before convert: a-%d ",a); convert(a); printf("After convert: a-%d ",a); b-convert2(a); printf("After convert2: a=%d b=%d ",a,b); return 0; 16 } 17 18 19 void convert (int a){ a=2*a; 20 } 21 22 23 int convert2(int b){ int a; 24 a-4; 25 b=a*b; 26 return (b); 27 Figure 1. I- b. Complete the following table that shows the status of each LED after the program was executed: i. While the switch IS NOT PRESSED [6 marks] LED no. Status (Turn ON, Turn OFF or Blinking) 1 2 3 4 5 6 ii. While the switch IS PRESSED (continuously hold the press) LED no. Status (Turn ON, Turn OFF or Blinking) 1 2 3 4 5 6 Question 3 Figure 3a shows the Arduino board that integrated with 6 LEDs and 1 switch, while Figure 3b shows the executed C program which is simulated using Tinkercad. LED 3 LED 2 LED 1 DIGITAL (PWM-) O UNO ARDUINO IOREF RESET POWER Figure 3a 0+X*| ON ANALOG IN LED 4 LED 5 LED 6 Given the C program in Figure 1, find the output of the program main.c 1 #include 2 3 void convert(int); 4 int convert2(int); 5 6 int main(void) { 7 int a=5; 8 10 11 12 13 14 15 int b; printf("Before convert: a-%d ",a); convert(a); printf("After convert: a-%d ",a); b-convert2(a); printf("After convert2: a=%d b=%d ",a,b); return 0; 16 } 17 18 19 void convert (int a){ a=2*a; 20 } 21 22 23 int convert2(int b){ int a; 24 a-4; 25 b=a*b; 26 return (b); 27 Figure 1. I- b. Complete the following table that shows the status of each LED after the program was executed: i. While the switch IS NOT PRESSED [6 marks] LED no. Status (Turn ON, Turn OFF or Blinking) 1 2 3 4 5 6 ii. While the switch IS PRESSED (continuously hold the press) LED no. Status (Turn ON, Turn OFF or Blinking) 1 2 3 4 5 6 Question 3 Figure 3a shows the Arduino board that integrated with 6 LEDs and 1 switch, while Figure 3b shows the executed C program which is simulated using Tinkercad. LED 3 LED 2 LED 1 DIGITAL (PWM-) O UNO ARDUINO IOREF RESET POWER Figure 3a 0+X*| ON ANALOG IN LED 4 LED 5 LED 6
Expert Answer:
Answer rating: 100% (QA)
There are some syntax errors in the provided C code Lets correct those errors and anal... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
Under Social Security, the family of a worker who dies while fully insured at the time of death has a right to survivors' benefits. True False
-
One approach to investigating the consequences of a major oil spill in the Gulf of Mexico is to look at the amount of heavy metals that have been incorporated in the shells of oysters. Oysters...
-
The two hydrogens of a methylene group adjacent to an asymmetric carbon are not equivalent hydrogens because they are in different environments due to the asymmetric carbon. (You can verify this...
-
Describe what is meant by parent holding company model.
-
Deriving permanent and temporary differences from financial statement disclosures. Pownall Company reports the following information for a year: Book Income before Income Taxes ........... $318,000...
-
What is the importance of time (n) number of years in TVM? What is the importance of the interest rate (R) in TVM? What is the importance of the initial amount of money someone chooses to invest (PV)
-
Monica Weyulu had the following income for the year of assessment ending 28 February 2020: N$ Salary 10 000 Director's Fee 2 000 Interest from First National Bank 1 000 Interest from Bank in the US 4...
-
Sopan was happy to lend his textbook to a fellow student who seemed bright and friendly. He was surprised when his classmate did not return it. His assumption that the bright and friendly student...
-
Leslie repeats a unique sound, known as a __________when she engages in meditation.
-
What are the functions of emotions?
-
Many people enjoy watching movies, sporting events, and music performances in crowded theaters and arenas more than they like watching them at home alone. Which theory of emotions may help explain...
-
Dreams most often occur in __________sleep.
-
To solve a linear programming problem with thousands of variables and constraints a) Personal computer can be used b) A mainframe computer is required c) The problem must be partitioned into subparts...
-
You are a Loan Officer with an Investment Bank. Today you need to set your lending parameters. They are: LTV: 55% 10 Year T-Bill: TBD Rate Markup: 300 Basis Points Term: 30 Years Amortization: 30...
-
A food processor claims that at most \(10 \%\) of her jars of instant coffee contain less coffee than claimed on the label. To test this claim, 16 jars of her instant coffee are randomly selected and...
-
Refer to Exercise 4.2. (a) Determine the cumulative probability distribution \(F(x)\). (b) Graph the probability distribution of \(f(x)\) as a bar chart and below it graph \(F(x)\). Data From...
-
Four emergency radios are available for rescue workers but one does not work properly. Two randomly selected radios are taken on a rescue mission. Let \(X\) be the number that work properly between...
Study smarter with the SolutionInn App