3.10 Identify and correct the errors in each of the following. [Note: There may be more than one
a) if ( age >= 65 );
puts( "Age is greater than or equal to 65" );
else
puts( "Age is less than 65" );
b) int x = 1, total;
while ( x <= 10 ) {
total += x;
++x;
}
c) While ( x <= 100 )
total += x;
++x;
d) while ( y > 0 ) {
printf( "%dn", y );
++y;
2. (Sales Commission Calculator) One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop a program that will input each salespersons gross sales for last week and will calculate and display that salespersons earnings. Process one salesperson's figures at a time. Here is a sample input/output dialog:
Enter sales in dollars (-1 to end): 5000.00
Salary is: $650.00
Enter sales in dollars (-1 to end): 1234.56
Salary is: $311.11
Enter sales in dollars (-1 to end): -1
3. (Diameter, Circumference and Area of a Cirle) Write a program that reads the radius of a circle (as a float value) and computes and prints the diameter, the circumference and the area. Use the value 3.14159 for p.
4. Factorial) The factorial of a nonnegative integer n is written n! (pronounced n factorial) and is defined as follows: n! = n (n - 1) (n - 2) 1 (for values of n greater than or equal to 1) and n! = 1 (for n = 0). For example, 5! = 5 4 3 2 1, which is 120.
a) Write a program that reads a nonnegative integer and computes and prints its factorial.
5. (Calculating the Sum of Even Integers) Write a program that calculates and prints the sum of the even integers from 2 to 30.
6. (Triangle-Printing Program) Write a program that prints the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single printf statement of the form printf( "%s", "*" ); (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an appropriate number of blanks.]
7. (Even or Odd) Write a program that inputs a series of integers and passes them one at a time to function even, which uses the remainder operator to determine whether an integer is even. The function should take an integer argument and return 1 if the integer is even and 0 otherwise.
8. (Temperature Conversions) Implement the following integer functions: a) Function celsius returns the Celsius equivalent of a Fahrenheit temperature.