Sunteți pe pagina 1din 1

CAD Lab Workshop

Tutorial 2 on C

1. For a quadratic equation ax2 +bx+c = 0 find the roots of the equation.
Depending on the user given values of a, b and c, your program should
decide whether the roots will be real or complex. For complex roots
you can calculate and print real and imaginary parts separately.

2. For a user given number, write a program to find sum of the digits of
the number.

3. A library charges a fine for every book returned late. For first 5 days the
fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is
5 rupees. If you return the book after 30 days your membership will be
cancelled. Write a program to accept the number of days the member is
late to return the book and display the fine or the appropriate message.

4. A fibonacci series is such that its nth member is sum of (n 1)th and
(n 2)th members. First two members are 1 and 1. So the series is
1, 1, 2, 3, 5, 8, . Write a program using while loop to print all the
members in the series upto a user given number N.

5. Write a C program using FOR loop to perform a matrix multiplication

C = AB where A is a user given 2 3 and B is a user given 3 3