C++ examples for Function:Function Return
Return a value from a function
#include <iostream> using namespace std; char cfunc(int i) { if(i == 0)//from ww w. ja v a2 s . c om return 'a'; if(i == 1) return 'g'; if(i == 5) return 'z'; return 'c'; } int main() { cout << "type an integer: "; int val; cin >> val; cout << cfunc(val) << endl; }