Experimental Report of Nanjing University of Information Engineering
Experiment Name C + + simple programming-2 experimental date 2018-3-20 score Instructor Shan Department of Soft College professional embedded + soft-embedded grade 2017 Frequency (1) name Schhao Yang School number 20161334026
[TOC]
First, the purpose of the experiment
- Understanding and mastering the definition and use of functions in C + +
- Understanding the difference between value passing and reference passing during function calls in C + +
- Flexible, comprehensive use of C + + branch structure, loop structure and continue, break and other applications to solve the problem of programming.
II. Preparation of the experiment
Before the experiment, please preview/review the specified content around the following contents
- Definition and usage of functions in C + +
Read and learn the 3.1 sections of the textbook, Study/review the following:
- The syntax form of the function definition, function parameter and argument, return value function, function call form; function parameter
Number of delivery methods (value passing and reference passing)
- Specify Learning Examples: 3rd Chapter 3-1, example 3-4, example 3-11, example 3-12
- Use of the IF statement, switch statement, while statement, Do...while statement in C + + and its nested usage
- The use of continue statements and break statements in C + +
Iii. contents of the experiment
- Validation experiments
- Run the textbook P68 example 3-4 source code, to understand the function declaration, function definition, function call method, to
and parameters, arguments, the function of the return value, and the value passing process of the parameter.
- Run the textbook P78 example 3-11 source code, P79 example 3-12 source code, observe the difference between the results of the operation, combined
3.1.3 section Analysis, understanding and summarizing the difference between value passing and reference passing
- Programming experiments
The following are implemented in C + + programming:
- Exercise 2-28 (Textbook P63)
- Exercise 2-29 (Textbook P63)
- Exercise 2-32 (Textbook P63)
- Exercise 2-34 (Textbook P63)
Iv. conclusion of the experiment
- Validation Experiment Section
- function declarations and functions define the respective roles, the difference between the two;
- A function declaration is used to declare a new function, such as
int max(int a,int b);
- A function definition refers to the occurrence of a function's contents, for example
int max(int a,int b){return a>b?a:b;}
[0318] C + + Simple programming-2