CAN ANYONE ANSWER ME THIS QUESTION
Name:_______________________________________________
ET204 Summer 2016 Exam 1
This exam is open notes and book, please no use of cell phones, other internet sources, headphones, etc. Exam will result in a 0 if caught.
For questions 1-5, please complete each question.
1. Write a loop to print all multiples of three from 0 to 100.(2 points)
2. What causes an infinite loop? How do we break it? (2 points)
3. Find 3 mistakes in the code and correct them: (2 points)
#include <stdio.h>
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. (2 points)
5. What is the output of the following code? (2 points)
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. (45 points)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. (45 points) 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