You are on page 1of 2

Faculty of Engineering, D.E.

I
EEM 303 – Data Structures using C
Home Assignment 1 (UNDER AA)
Submission deadline: August 6, 2018

Instructions: Turn in handwritten answers to all the questions given in a Notebook.

Section A

1. Write a c program to check given number is prime number or not. Make it as efficient as
possible.
2. Write a c program to find the roots of a quadratic equation given the coefficients a, b and
c.
3. The sine of x can be calculated approximately by summing the first n terms of the infinite
series: sin (x) = x - x3 /3! + x5 /5! – x7 /7! + . . ., where x is expressed in radians (p
radians = 180 degrees). Write a C program that will read in a value for x and will calculate
sin (x) by summing the first n terms of this series (n being specified by the user). Modify
this program so as to continue adding successive terms until the value of the next term
becomes smaller (in magnitude) than 105.
4. Write a function takes two parameters, an array (A) of class test marks and the number
of elements (n). The function computes and prints the highest, lowest, and average marks.
Assume that marks are integers in the range [0,40].
5. Write a program that reads a string of characters from keyboard and displays the reversed
string.
6. Write a C program to input an array a of specified size k and do the following:
a. Find the minimum and maximum of the array
b. Find the mean, median and mode of the set of integers in the array given that they
are between 0 and 99.
c. Find the standard deviation of the integers in array a.
d. Implement sequential search for a given integer k.
e. Implement binary search for a given integer k.
f. Implement Bubble sort to sort the array a.
g. Implement Selection sort to sort the array a.
h. Implement Insertion sort to sort the array a.

7. Write a program in C which reads a matrix from the console and computes and displays
its transpose.
8. Write a program in C which reads two matrices from the console and computes and
displays the sum of the two matrices.
9. Write a program in C which reads two matrices from the console and computes and
displays the product of the two matrices.
10. Write a c program to find out sum of digits of a given number.
11. Write a c program to find out the L.C.M. and H.C.F. of two numbers.

Section B

12. Write a C program that reads the x and y coordinates of three points A, B, C in the plane
and does the following:
a. Checks if the points are collinear. If they are, it prints an appropriate message.
b. If they are not collinear, compute the distances AB, BC and AC between them. It
then computes the area of the triangle ABC and prints it.
c. Determines if the triangle ABC is equilateral, isosceles, or neither, and prints the
result.
d. Prints the largest angle of the triangle and determine whether the angle is right
angle, acute or obtuse.
e. Finds the circle that passes through all three points and prints the co-ordinates of
the centre and the dimension of the radius of the circle.

13. Write a program that computes the number of prime numbers present in a given range
[x1, x2].

14. A palindrome is a word, phrase or sentence that reads the same way either forward or
backwards. Malayalam and 1234321 are examples of palindromes. Write a C program
that will read a line of text (which could be a word, phrase or sentence) and determine if
it is a palindrome.

15. Write a C program that takes as input a number and computes and prints the following:
a. the sum of the digits of the number
b. the number, reversed
c. the sum of the original number and the reversed number

16. Write a program that reads a character, C, and then does the following:
a. If the value of C is 'D', then it reads a decimal number (integer) and prints it in
binary form. For example, it may read 5 and print 101. The conversion from
decimal to binary must be performed by your program.
b. If the value of C is 'B', then it reads a number in binary, and prints it in decimal.
For example, it may read 1101 and print 13. The conversion from binary to decimal
must be performed by your program.

You might also like