Professional Documents
Culture Documents
Functions Lab 1
Functions Lab 1
#include <iostream>
using namespace std;
//prototypes
void DemonstrateProc1();
void DemonstrateProc2(int num);
int main()
{
cout << "?. Execution starts with main. " << endl;
DemonstrateProc1();
cout << "?. Then we come here. " << endl;
DemonstrateProc2(100);
cout << "?. Finally we come here. "<< endl;
return 0;
}
//****************************
void DemonstrateProc1()
{
cout << "?. This is a sample procedure." << endl;
}
//****************************
void DemonstrateProc2(int num)
{
cout << "?. This is another sample procedure. " << endl;
cout << " num is an argument or parameter. " << endl;
cout << " The value of num is " << num << endl;
}
1. Type in the above program including your name and date as a comment. Before running
the program, change each of the question marks to the numbers 1 through 5 indicating
the order in which that line will be executed. Run the program and check your numbers.
Fix and rerun if necessary. Submit the program and the output.
2. //RobbieKenderdine 4/26/2020
3. #include <iostream>
4. using namespace std;
5. //prototypes
6. void DemonstrateProc1();
7. void DemonstrateProc2(int num);
8. int main()
9. {
10. cout << "1. Execution starts with main. " << endl;
11. DemonstrateProc1();
12. cout << "3. Then we come here. " << endl;
13. DemonstrateProc2(100);
14. cout << "5. Finally we come here. "<< endl;
15. return 0;
16.}
17.//****************************
18.void DemonstrateProc1()
19.{
20. cout << "2. This is a sample procedure." << endl;
21.}
22.//****************************
23.void DemonstrateProc2(int num)
24.{
25. cout << "4. This is another sample procedure. " << endl;
26. cout << " num is an argument or parameter. " << endl;
27. cout << " The value of num is " << num << endl;
28.}
29.
Type in the above program as lines.cpp. Add a comment to include your name and date. Compile
and run. Change the program so that it will print 2 lines of asterisks before the welcome message
and 4 lines of asterisks after the welcome message. Compile and run.
3. On the program label the formal argument(s) and the actual argument(s).
4. Draw a hierarchy chart for the program.
{
PrintLines
PrintLines2
PrintLines4
*************************************
*************************************
Welcome Home!
*************************************
*************************************
*************************************
*************************************