Professional Documents
Culture Documents
Functions Why Functions?
Functions Why Functions?
Functions
Why functions?
Break longer jobs into conceptually smaller jobs which are precisely
defined.
C program generally consists of many small functions.
A piece of a code which repeats at many places can be written only once
and used again and again.
Debugging and maintenance is easy.
return
return sinValue;
sinValue;
}}
return
return 0;
0;
}}
main()
main() {{
int
int I;I;
II == 4;
4;
printf(“%d\n”,
printf(“%d\n”, I);
I);
newI(I);
newI(I);
printf(“%d\n”,
printf(“%d\n”, I);
I);
}}
for
for (( xx == 0;
0; xx <=
<= 1;
1; xx +=
+= 0.1
0.1 ){
){
val = coef[0];
val = coef[0];
for
for (( ii == 1;
1; ii <=
<= order;
order; i++i++ ))
val
val +=
+= coef[i]
coef[i] ** pow(x,i);
pow(x,i);
prinf(“%f\t%f“,x,val);
prinf(“%f\t%f“,x,val);
}}
}}