Write a loop to print all multiples of three from 0 to


For questions 1-5, please complete each question.

1. Write a loop to print all multiples of three from 0 to 100.

2. What causes an infinite loop? How do we break it?

3. Find 3 mistakes in the code and correct them:

#include
int main();
{
float area = 0, length = 6;
area = length * width;

printf("The area of the rectangle is %f \n", &area);
return 0;
}

4. True or False. A switch statement can allow a range of values for a variable on a single case statement.

5. What is the output of the following code?

a = 0, b=0, c=0, d=0.

for (a = 0; a<=10; a++)
{
if (b<= -1)
{
b-=2;
c++;
d+=5;
}
else
{
for (b=0; b>=-5; b--)
{
c = a + b;
d = c - a;
}
printf("\n %d %d %d %d \n", a, b, c, d);
}
}

6. Write a program to compute the impedance, Z, and inductance, L, of an electrical coil given voltage, V, current, I, resistance, R, and frequency, F, for six different circuits. Have the user input V, I, R, and F each time. Use the following formulas for your calculation:

Z = V/I
Z2 = XL2 + R2
XL = sqrt(Z2 - R2)
L = XL / (2*PI*F)
L is the inductance
XL is the reactance
Z is the impedance.

Each iteration should print out the voltage, current, reactance and impedance.

Use these input values for your 6 iterations:

Iteration

Voltage

Current

Resistance

Frequency

1

120

12

8

50

2

250

14

7

50

3

150

16

9

50

4

100

10

5

50

5

220

12

8

50

6

300

19

9

50

7. Write a program to compute the periods of a simple pendulum for arm lengths starting at 12 inches and reaching a period of less than or equal to 3.45.

a. The arm length L in feet varies from 1 to n.

period = 2*PI * sqrt(L/g)

where g = 32.2 ft/sec2

For this problem, for each iteration, print out the length and period and increase the length by 1 foot.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write a loop to print all multiples of three from 0 to
Reference No:- TGS01626629

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)