[0318] C + + Simple programming-2

Source: Internet
Author: User
Tags function definition

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 asint max(int a,int b);
        • A function definition refers to the occurrence of a function's contents, for exampleint max(int a,int b){return a>b?a:b;}

[0318] C + + Simple programming-2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.