Friday, November 30, 2007

(CS05144) COMPUTER PROGRAMMING LAB

1. Write a C program to evaluates the following algebraic expressions after reading
necessary values from the user:
a) ax+b/ax-b
b) 2.5 log x + cos 320 + | x2 –y2 | + v 2xy
c) 1/α √2π e- (x-m/ √2σ)2
2. Write a C program for the following
a) Printing three given integers in ascending order
b) Sum of 1 + 2+ 3 + _ _ _ _ _ n
c) 1 + x2/2! + x2/ 4!+ _ _ _ _ _ upto ten terms
d) x +x3/3! + x5/5!+ _ _ _ _ _ upto 7th digit accuracy
e) Read x and compute Y =1 for x > 0
Y=0 for x = 0
Y= -1 for x<0
3. Write C program using FOR statement to find the following from a given set
of 20 integers.
i) Total number of even integers. ii) Total number of odd integers.
iii) Sum of all even integers. iv) Sum of all odd integers.
4. Write a C program to obtain the product of two matrices A of size (3X3) and B
of size (3X2). The resultant matrix C is to be printed out along with A and B.
Assume suitable values for A & B.
5. Using switch-case statement, write a C program that takes two operands and
one operator from the user, performs the operation and then prints the answer.
(consider operators +,-,/,* and %).
6. Write C procedures to add, subtract, multiply and divide two complex numbers
(x+iy) and (a+ib). Also write the main program that uses these procedures.
7. The total distance traveled by vehicle in ‘t’ seconds is given by distance =
ut+1/2at2 where ‘u’ and ‘a’ are the initial velocity (m/sec.) and acceleration
(m/sec2). Write C program to find the distance traveled at regular intervals of
time given the values of ‘u’ and ‘a’. The program should provide the flexibility
to the user to select his own time intervals and repeat the calculations for
different values of ‘u’ and ‘a’.
8. A cloth show room has announced the following seasonal discounts on
purchase of items.
Discount (Percentage)
Amount Mill Cloth Handloom items
1-100 - 5.0
101-200 5.0 7.5
201-300 7.5 10.0
Above 300 10.0 15.0
PURCHASE
Write a C program using Switch and If statements to complete the net amount
to be paid by a customer.
9. Given a number, write a C program using while loop to reverse the digits of the
number. Example 1234 to be written as 4321.
10. The Fibonacci sequence of numbers is 1,1,2,3,5,8… based on the recurrence
relation
f(n) = f (n-1) + f (n-2) for n>2.
Write a C program using do-while to calculate and print the first n fibonacci
numbers.
11. Write C programs to print the following outputs using For loop.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
12. Write a C program to extract a portion of a character string and print the
extracted string. Assume that m characters are extracted starting with the nth
character.
13. A Maruthi Car dealer maintains a record of sales of various vehicles in the
following form:
Vehicle type Month of
Sales Price (Rs).
Maruthi – 800 02/87 75,000
Maruthi – DX 07/87 95,000
Gypsy 04/88 1,10,000
Maruthi Van 08/88 85,000
Write a C program to read this data into a table of strings and output the
details of a particular vehicle sold during a specified period. The program
should request the user to input the vehicle type and the period (Starting
month & ending month).
14. Write a function that will scan a character string passed as an argument and
covert all lower case characters into their upper case equivalents.
15. Implement the following data structures using Arrays
i) Stacks ii) Linear Queues iii) Circular queues
16. Implement binary search tree using linked list and perform the following
operations.
i) Insertion ii) Deletion iii) Inorder Traversal iv) Preorder Traversal
v) Post Order Traversal.
17. Singly linked list and doubly linked lists
i) Insertion ii) Deletion iii) Lookup
18. i) Implement stack using singly linked list.
ii) Implement queue using singly linked list.
19. Implement the following sorting techniques.
i) Bubble sort ii) Insertion Sort iii) Quick Sort iv) Heap Sort.
20. Implement the following searching method.
i) Sequential Search ii) Binary Search
21. i) Conversion of Infix expression to Postfix notation.
ii) Simple expression evaluator, that can handle +,-,/ and *.
22. Implement the algorithms for the following iterative methods using C to find
one root of the equation
9x1+2x2+4x3=0
x1+10x2+4x3 = 6
2x1-4x2+10x3 = -15.
23. Write Computer programs to implement the Lagrange interpolation and Newton-
Gregory forward interpolation.
24. Implement in ‘C’ the linear regression and polynomial regression algorithms.
25. Implement Traezoidal and Simpson methods.

No comments: