1.
Write a C program that accepts 4 real numbers from the keyboard and prints out
the difference (using 4-decimal places) of the maximum and minimum values of
these numbers.
Test data and expected output:
Enter four numbers: -1.5 2 7.5 11.2
Difference is 12.7000
2. Write a C program that accepts a real number x from the keyboard and prints out the
corresponding value of sin(1/x) using 4-decimal places.
Test data and expected output:
Enter value of x: 0.5
Value of sin(1/x) is 0.9093
Enter value of x: 0
Value of x must be nonzero: try again
3. Write a C program that accepts (from the keyboard) a positive integer less than 1000
and prints out the sum of the digits of this number.
Test data and expected output:
Enter a +ve no less than 1000: -4
Entered number is out of range
Enter a +ve no less than 1000: 1234
Entered number is out of range
Enter a +ve no less than 1000: 546
Sum of the digits of 546 is 15
4. A decimal number between 0 and 32 exclusive can be expressed in binary system as
x4x3x2x1x0, where xi’s are either zero or one. Write a C program that accepts (from
the terminal) a decimal number in the above range and prints out the equivalent
binary representation with leading bit 1.
Test data and expected output:
Enter a +ve no less than 32: -5
Entered number is out of range
Enter a +ve no less than 32: 21
Binary equivalent of decimal number 21 is 10101
Enter a +ve no less than 32: 14
Binary equivalent of decimal number 14 is 1110
Enter a +ve no less than 32: 35
Entered number is out of range
5. Write a C program that accepts coordinates of two-dimensional points A and B and
prints out (using two decimal places) the distance between A and B. It also prints
out the coordinates (using two decimal places) of the midpoint of A and B.
Test data and expected output:
Enter coordinates of points A: -1 3
Enter coordinates of points B: 2 -1
Distance between A and B is 5.00
The coordinates of midpoint of A and B are (0.50,1.00)