C++ local variables pass to functions
#include <iostream> using namespace std; #include <iomanip.h> pr_init(char initial); // Prototypes discussed later. pr_other(int age, float salary); int main()/*from ww w. ja va2s . c om*/ { char initial; // Three variables local to main(). int age; float salary; // Fill these variables in main(). cout << "What is your initial? "; cin >> initial; cout << "What is your age? "; cin >> age; cout << "What is your salary? "; cin >> salary; pr_init(initial); pr_other(age, salary); return 0; } pr_init(char initial) { cout << "Your initial is " << initial << "\n"; return 0; } pr_other(int age, float salary) { cout << "You look young for " << age << "\n"; cout << "And " << setprecision(2) << salary << " is a LOT of money!"; return 0; }