C examples for Function:Function Definition
Have multiple return statements in a function
#include <stdio.h> float bonus(char x); int main()/*from w w w .j ava2s . c o m*/ { char name[20]; char level; float b; printf("Enter employee name:"); gets_s(name); printf("Enter bonus level (0, 1 or 2):"); level=getchar(); b=bonus(level); b*=100; printf("The bonus for %s will be $%.2f.\n",name,b); return(0); } /* Calculate the bonus */ float bonus(char x) { if(x=='0') return(0.33); /* Bottom-level bonus */ if(x=='1') return(1.50); /* Second-level bonus */ return(3.10); /* Best bonus */ }