Exercise 2.1
1. m = 10
n = 21
2. My name is Jane Doe.
I live in Ann Arbor, MI
and I have 11 years of programming experience.
3. Replace the line printf("\n"); with printf(" ");
4. printf("Type three integers: ");
scanf("0 0 0", &first, &second, &third);
5
Exercise 3.1
1. x! =y false
x < y true
x >= y x true
x = y + x y true
2. ans = (100>95) + (50<95); ans = q or 50
3. if (deduct < balance);
balance = balance deduct;
printf("New balance is %.2f\n", balance);
cfw_
else;
printf("Deduction of %.2f refused.\n"
Exercise 4.1
1. Int leg1, leg2;
printf( Please enter the value for the two legs of the triangle\n);
scanf(%lf %lf\n, &leg1, &leg2);
prin( The hypotenuse calculated from leg1 and leg2 is 0 0\n,
sqrt(pow(leg1,2) pow(leg2,2);
return0;
2. A) 8
B) Integer
C) A
Flowcharts
Task 1:
Start
List of odd numbers less
than 10
Put 1 in the
number
Output the number
No
Add 2 to the
number
Is number less than 10?
Yes
End
Task 2:
Task 3:
Project Part 1
Requirements: designing a circuit that will automatically adjust circuit resistance until
the max power is delivered to the load. The circuit consists of a programmable power
supply, a variable resistor, a fixed resister, and a programmable
Algorithm and Flowcharts
TASK 1:
1.
2.
3.
4.
Output Convert miles to kilometers
Output Please enter the distance in miles
Input dist_in_miles
Convert dist_in_miles to kilometers
a) Multiply dist_in_miles by 1.609
b) Put the result in dist_in_kms
5. Output