Professional Documents
Culture Documents
HOME WORK: #2
School: Department:
Part-A
Note: All programs must have relevant comments after every statement written.
Q1. Give the function header for each of the following functions:
b) Function instructions that does not receive any arguments and does not receive any arguments
and does not return a value.
c) Function hypotenuse that takes two double-precision floating point arguments, side1 and side2
and returns a double precision floating point result.
d) Function intToFloat that takes an integer argument number and returns a floating point result.
Q2. Write a function called hypotenuse that calculates the length of hypotenuse of a right triangle when
the other two sides are given. Use this function on a program to determine the length of hypotenuse for
each of the following triangles.
1 3.0 4.0
2 8.0 15.0
Q3. Write a program that simulates coin tossing. For each toss of the coin the program should print Heads
or Tails. Let the program toss the coin n times, and count the number of times each side of the coin
appears. Print the results. The program should call a separate function flip that takes no arguments and
returns 0 for tails and 1 for heads.
Part-B
Note: All programs must have relevant comments after every statement written.
Q. 4 Write a program to find all the fibonacii series numbers that exist between two given numbers by the
use of
a) recursive function
b) by using loop
Fibonacii series is 0, 1, 1, 2, 3, 5,……..
Q. 5 Write a program to generate m × n size matrix with the help of two dimensional arrays with the
following features:-
a. Sum of all the elements of m × n size matrix should not be less than 300.
b. If we sum all the elements in each row of matrix separately, sum must be the multiple of 3 and 5.
Note: No initialization data will be provided and all the values will be entered on the run time by the user.
If user does not satisfy any condition as specified above, he/she should be prompted to enter the values
again.
Q. 6 What do you mean by pass by value and pass by reference. Write a program (except swap
example) to show pass by value and pass by reference.