- •Vasyl Yatskiv,
- •Content
- •Introduction
- •1. Theory
- •1.1. Arithmetic Operators
- •1.2. Relational Operators
- •1.3. Logical Operators
- •1.4. Increment/Decrement Operators
- •1.5. Assignment Operator
- •1.6. Conditional Operator
- •1.7. Comma 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: _______________________________________________
2. Lab Overview
2.1. Read the theory and try Control Exercises.
2.2. Develop the algorithm flowchart to solve a problem according to individual case from the Table below.
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.
# |
Task |
|
|
Calculate an average of 5 numbers (for positive values only) |
|
|
Calculate a height (h) of triangular with known area (S) and base side (a) |
|
|
Find an area of triangular with known sides (a, b, c) according to Heron's formula |
|
|
Define if the value is inside the indicated range |
|
|
Find a sum of all numbers in the indicated range |
|
|
Find out if the number is odd or pair |
|
|
Calculate an area of circle with known diameter |
|
|
Convert inputted kilograms into pounds |
|
|
Convert your height to feet and inches while inputting only in inches |
|
|
Calculate body mass index |
|
|
Calculate number of seconds if user inputs time in hours, minutes and seconds separately |
|
|
Output number of days if user inputs period in years, months and days |
|
|
Calculate number of hours, minutes and seconds if user inputs time in seconds |
|
|
Report the miles per gallon your car has gotten if you know how many miles you have driven and how many gallons of gasoline you have used |
|
|
Write a program that asks you to enter an automobile gasoline consumption figure in the European style (liters per 100 kilometers) and converts to the U.S. style of miles per gallon |
|
|
Develop currency convertor between Ukrainian Hryvna, US Dollar and Euro |
|
|
Create a convertor between Fahrenheit and Celsius temperature |
|
|
Calculate the total cost of pens and copybooks required by a pupil if you know prices and quantities |
3. Report Structure
Title page (Annex A)
Task overview
Algorithm’s flowchart
Program code
Program running screenshots
Conclusions
4. Control Exercises
4.1. Write expressions for the following:
To test if a number n is even.
To test if a character c is a digit.
To test if a character c is a letter.
To do the test: n is odd and positive or n is even and negative.
To give the absolute value of a number n.
To give the number of characters in a null-terminated string literal s.
4.2. Add extra brackets to the following expressions to explicitly show the order in which the operators are evaluated:
(n <= p + q && n >= p - q || n == 0)
(++n * q-- / ++p - q)
(n | p & q ^ p << 2 + q)
(p < q ? n < p ? q * n - 2 : q / n + 1 : q - n)
4.3. What will be the value of each of the following variables after its initialization?
double d = 2 * int(3.14);
long k = 3.14 - 3;
char c = 'a' + 2;
char c = 'p' + 'A' - 'a';
