PDA

View Full Version : sir i cant under stand function and cant apply it in program please help me



sana.pari
04-24-2011, 06:15 PM
Subject: assignment problem
sir i cant under stand function and cant apply it in program please help me

Support
04-24-2011, 06:15 PM
Dear student!
Functions are like sub tasks. They receive some information, do some process and provide result. Functions are invoked by calling program. Calling program calls a function by giving it some information and receives the result. This is the basic idea of a function. There are two things related to a function which are declaration and definition. Declaration is the prototype of the function, that includes the return type, name and argument list to the function and definition is the actual function code.

For example, a function is given below

double raiseToPow(double x ,int power)
{
double result;
int i;
result=1.0;
for(i=1;i<=power;i++)
{ result *= x;
}
return(result);
}

This function can not be executed untill we use it in a program. We would have to write program which will use this function.
Please consult lecture 9 for further descritpion. Try sample programs given in the lecture. Your concept will be clarified.