Tuesday, September 23, 2014

Day 6 - 1: Exercise function

1. Write a C program that accepts a number and square the number with the help of a function.
To do this,
a. Declare a function.
b. Accept the number.
c. Pass the number to the function and return the square of that number
Function prototype: int cal_square(int number);

2. Write a C program to find the area and perimeter of a circle.
Function prototype: float areaCircle(float radius);
Function prototype: float perimeterCircle(float radius);
Using the library: “Math.h” => PI = 3.14


3. Write a C program to calculate the factorial of an integer
Function prototype:  long factorial(int number);


4. Write a program with a function that takes two int parameters, adds them together, then returns the sum. The program should ask the user for two numbers, then call the function with the numbers as arguments, and tell the user the sum.
Function prototype: int calSum(int number1, int number2);

No comments:

Post a Comment