0% found this document useful (0 votes)
59 views2 pages

Test Data and Expected Output

The document outlines 4 programming problems: 1) A program to find the difference between maximum and minimum of 4 numbers. 2) A program to calculate sin(1/x) for a real number x. 3) A program to find the sum of digits of a positive integer less than 1000. 4) A program to convert a decimal number between 0-32 to binary. It also provides sample test data and expected output for each problem.

Uploaded by

msugnan9124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

Test Data and Expected Output

The document outlines 4 programming problems: 1) A program to find the difference between maximum and minimum of 4 numbers. 2) A program to calculate sin(1/x) for a real number x. 3) A program to find the sum of digits of a positive integer less than 1000. 4) A program to convert a decimal number between 0-32 to binary. It also provides sample test data and expected output for each problem.

Uploaded by

msugnan9124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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)

You might also like