Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лабораторні, на англійській.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
605 Кб
Скачать
☆

1.8. Default Arguments

Default argument is a programming convenience which removes the burden of having to specify argument values for all of a function’s parameters. For example, consider a function for reporting errors:

void Error (char *message, int severity = 0);

Here, severity has a default argument of 0; both the following calls are therefore valid:

Error("Division by zero", 3); // severity set to 3

Error("Round off error"); // severity set to 0

As the first call illustrates, a default argument may be overridden by explicitly specifying an argument.

2. Lab Overview

2.1. Read the theory and try Control Exercises.

2.2. Develop the algorithm flowchart to solve a numerical integration problem using Rectangle method, Trapezoidal rule and Simpson's rule for a function according to individual case from the Table below.

Rectangle method:

, where

Trapezoidal rule:

, where

Simpson's rule:

, where

An interval beginning (a), end (b) and subintervals number (n) should be inputted from a keyboard. User-defined functions should be used to calculate a function value and integral values according to each numerical integration method.

2.3. Write the program code according to the developed algorithm.

2.4. Debug the program, run it and make screenshots.

2.5. Prepare the Lab Report according to the required structure.

#

Function for numerical integration

Recursive problem

Power of the inputted number

Factorial of the inputted number

Countdown from inputted number till 0

Division of inputted number and all received results by 2 while the result is not less than 2

Multiplication table for 0..9 by the inputted number

Power of the inputted number

Factorial of the inputted number

Countdown from inputted number till 0

Division of inputted number and all received results by 2 while the result is not less than 2

Multiplication table for 0..9 by the inputted number

Power of the inputted number

Factorial of the inputted number

Countdown from inputted number till 0

Division of inputted number and all received results by 2 while the result is not less than 2

Multiplication table for 0..9 by the inputted number

Power of the inputted number

Factorial of the inputted number

Countdown from inputted number till 0

Division of inputted number and all received results by 2 while the result is not less than 2

Multiplication table for 0..9 by the inputted number