Professional Documents
Culture Documents
2. Write a C program to compute the number in the Fibonacci series which is closest [6] [CO4]
to the given number.
For example, if the input is 15, the closest number in the Fibonacci
series is 13.
Use a function to compute the number. (Use Call By Reference
mechanism)
3. Define a structure customer with members custid, custname and order. Order is [10] [CO4]
another structure with members named nut_qty, bolt_qty and washer_qty. The shop
charges the following prices: Rs. 5 per bolt, Rs. 3 per nut and Rs. 1 per washer.
Write a program that asks the user for the custid, number of bolts, nuts, and washers
in their purchase and then calculates and prints out the total. As an added feature,
the program checks the order. A correct order must have at least as many nuts as
bolts and at least twice as many washers as bolts; otherwise the order has an error.
If the order is ok, then the cost of the order is printed out.
Few sample runs are as follows:
Enter order (bolts, nuts, washers): 10 10 20
Total price: Rs. 100
Do you want to continue (y/n): y
Enter order (bolts, nuts, washers): 10 20 20
Error! Too many nuts!!
Use function to realize the above requirement (Employ passing a structure to a
function).
Page 1 of 1