Functions are the self-contained program that contains several block of
statement which performs the defined task. In C language, we can create one or more
Functions according to the requirements.
Usually, In C programs flows from top left to right bottom of main() functions. We can
create any number of functions below that main() functions. These function are call from main() function.
Requirement while creating a functions.
- Declare a function
- Call statement
- Definition of function.
function.
WAP to calculate simple interest using function
#include
float interest(void); //function declaration
int main()
{ float si;
si=interest(); //function call
printf("Simple interst is %.2f\n",si);
return 0;
}
float interest() //function definition
{
float p,t,r,i;
printf("Enter Principal, Time and Rate");
scanf("%f%f%f",&p,&t,&r);
i=(p*t*r)/100;
return i; //function return value
}
0 Comments
I really appreciate for your words. Thank you very much for your comment.