C Programming

Answers: Practise Exercise 2: Assignments

1. Assign the value of the variable number1 to the variable total


	total = number1;

2. Assign the sum of the two variables loop_count and petrol_cost to the variable sum


	sum = loop_count + petrol_cost;

3. Divide the variable total by the value 10 and leave the result in the variable discount


	discount = total / 10;

4. Assign the character W to the char variable letter


	letter = 'W';

5. Assign the result of dividing the integer variable sum by 3 into the float variable costing. Use type casting to ensure that the remainder is also held by the float variable.


	costing = (float) sum / 3;


ęCopyright B Brown. 1984-1999. All rights reserved.