- •Vasyl Yatskiv,
- •Content
- •Introduction
- •1. Theory
- •1.1. Arithmetic Operators
- •1.2. Relational Operators
- •1.3. Logical Operators
- •1.4. Increment/Decrement Operators
- •1.6. Conditional Operator
- •1.7. Comma Operator
- •1.5. Assignment Operator
- •1.8. The sizeof Operator
- •1.9. Operator Precedence
- •1.10. Simple Type Conversion
- •2. Lab Overview
- •3. Report Structure
- •4. Control Exercises
- •5. References
- •Lab #2. Control structures
- •1. Theory
- •1.1. Simple and Compound Statements
- •1.2. The if Statement
- •1.3. The switch Statement
- •1.4. The while Statement
- •1.5. The do Statement
- •1.6. The for Statement
- •1.7. The continue Statement
- •1.8. The break Statement
- •1.9. The goto Statement
- •1.10. The return Statement
- •2. Lab Overview
- •3. Report Structure
- •4. Control Exercises
- •5. References
- •1. Theory
- •1.1. A Simple Function
- •1.2. Parameters and Arguments
- •1.3. Global and Local Scope
- •1.4. Scope Operator
- •1.5. Symbolic Constants
- •1.6. Inline Functions
- •1.7. Recursion
- •1.8. Default Arguments
- •2. Lab Overview
- •3. Report Structure
- •4. Control Exercises
- •5. References
- •Lab #4. Arrays, pointers, references and dynamic variables
- •1. Theory
- •1.1 Arrays
- •1.2 Multidimensional Arrays
- •1.3 Pointers
- •1.4 Dynamic Memory
- •1.5 Pointer Arithmetic
- •1.6 References
- •2. Lab Overview
- •3. Report Structure
- •4. Control Exercises
- •5. References
- •Lab #5. Structures
- •1. Theory
- •1.1 Introducing Structures
- •1.2 Using a Structure in a Program
- •1.3 Program Notes
- •1.4 Other Structure Properties
- •1.5 Arrays of Structures
- •2. Lab Overview
- •3. Report Structure
- •4. Control Exercises
- •5. References
- •Lab #6. Strings
- •1. Theory
- •1.1. Introduction to Strings
- •1.2. Concatenating String Constants
- •1.3. Using Strings in an Array
- •1.4. Reading String Input a Line at a Time
- •1.5. Line-Oriented Input with gets()
- •1.6. Introducing the string Class
- •1.7. Assignment, Concatenation, and Appending
- •1.8. More string Class Operations
- •1.9. More on string Class I/o
- •2. Lab Overview
- •3. Report Structure
- •4. Control Questions
- •5. References
- •Annex a Report’s Title Page
- •From discipline “Algorithmization and Programming” Topic: _______________________________________________
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 |
