CSIS1020 Fundamental of C programming Solution

1. Given the following conditions, write the appropriate decision statements:

For S less than or equal to 1000, R is assigned 50
For S in the range of 1001 to 4000, R is assigned 100
For s in the range of 4001 to 8000, R is assigned 250
For S greater than 8000, R is assigned 75.
2. Given the following set of code:

If (Width = Length)
printf(“Object is a squaren”);
else
printf(“Object is not a squaren”);

What would be printed if Width had a value of 5 and Length had a value of 5?
What would be printed if Width had a value of 5 and Length had a value of 12?
3. Given the following information:

If a person has a job code of ‘H’, their pay is based on the hours worked multiplied by their pay rate
If a person has a job code of ‘P’, their pay is based on the hours worked multiplied by the number of pieces they produce
If a person has a job code of ‘S’, their pay is based on their annual salary divided by 52
If a person has a job code of ‘C’, their pay is based on their total sales multiplied by their commission rate.
If a person has any other job code, then that is an error and an appropriate message should be displayed.

Create the necessary switch statement to implement this set of conditions.

Powered by