ADDITIONAL EXERCISE TASKS IN THE FIELD: BRANCHING IN THE PROGRAM (SELECTIONS STATEMENTS)
| This section provides examples of tasks in the field of branching in the program, with solutions. Try to solve the examples on your own, and use the solution to check or use if, after several attempts and a lot of effort, you still fail to solve the set task on your own. The solution will be displayed by clicking on the button next to the set task. The tasks are painted in different colors depending on the difficulty:
|
Creating web applications -introduce. Frontend and background development. Read more on webpage Creating web applicationsCreate a web application logo using the django framework by clicking on the image below ![]() |
Task 1: Free fall speedInput: In one line of the standard input there are two real values H and Vg (H≤3000, Vg≤300) which represent the initial height of the body in meters and the limit speed in m / s. Output Calculated fall speed as well as speed limit. Example 1 Input 10 12 Output "Height does not have to be more than 10 m for the body to reach a speed of 12 m / s" Example2 Input 50 78 Output "The height must be greater than 250 m for the body to reach a speed of 78 m / s" |
See what |
Task 2-High jump:If other results are known: competitor 1: 5.87m, 5.94m, x competitor 2: 5.89m, 5.84m, 5.75m; competitor 3: 5.6m, 5.87, y; determine the order of the competitors after this jump. Input Real numbers x and y, in the interval from (0 - 7) Output One real number, rounded to two decimal places, which represents the best result with the message that the competitor won. Example Input 5.45 5.76 Output The first competitor won with a jump of 5.94 |
Image by Peggy und Marco Lachmann-Anke from Pixabay
|
Task 3-Correctness of square dataEnter the pages of squares a, b, c and determine whether the entered data is correct (page lengths must be positive numbers). If so, calculate the area and volume. Input Enter the real numbers a, b, c in the three lines of the standard input Output Two real numbers representing the area and volume of a square or message that the data is incorrect
Example 1
Input 2 4 7 Output P=100cm2 V=56cm3 Example 2 Input 12 -4 7 Output The data is incorrect |
Image by Pete Linforth from Pixabay
|
Task 4-Enrollment at the faculty:Input 4 real numbers (0-100) should be entered in the first four lines. Output Show in 4 lines the answer for each candidate: "Eligible", or "Not eligible" Example Input 65 45 88 75 Output "Not eligible" "Not eligible" "Meets the requirements" "Meets the requirements" |
Image by OpenClipart-Vectors from Pixabay
|
Task 5-Determining the number of days by months:Determine the number of days for each month of the year. Predict the case and that the year is a leap year Input Two integers are entered from the standard input: M (0≤a≤12) - ordinal number of the month in the year G (0-2050) -current year Output Write one integer on the standard output - the number of days in that month Example 1 Input 3 2021 Output 31 Example 2 Input 2 2020 Output 29 |
Image by OpenClipart-Vectors from Pixabay
|
Task 7-Minimum of three integers:
| Write a program that determines the minimum value of the three entered values of the read temperature. Input From the standard input, three real numbers are entered, each in a separate row, which represent the values of the three read temperatures (-50.50) during the day. Output Print the value of the minimum temperature rounded to 2 decimal places on the standard output Example Input 12.34 5.64 7.45 Output 5.64 |
Image by Gerd Altmann from Pixabay
|
Task 8-Making color-RGB value:
| It is known that each shade of color can be obtained by mixing 3 components of red, green and blue. The components are represented by 3 integers whose values are (0-255). This is the RGB value. Create a program that, for the loaded values of R, G and B, determines which color shade predominates. Input Three integers are entered from the standard input, each in a separate line, representing R, G, B values between 0 - 255. Output Print the name of the dominant color on the standard output Example Input 50 130 170 Output "Blue" |
9. Car race
10. Code of Characters
11. Man do not be angry
| Create a program that simulates rolling dice using the rand () function from the stdlib.h file Pera plays "Man, don't get angry" and he has the opportunity to finish the round by entering his pawn in the house. He rolls the dice and needs to get either 2 or 4 to enter the house. If he gets 1 he will cross into the field right next to his house. The program should simulate rolling the dice, setting a random value of 1-6 using the rand function, and then print one of the following messages: "She's in the cottage" "It's close to the house" "He didn't move" |
Image by GooKingSword from Pixabay
|











