Перейти к основному содержанию
EDU-MMCS
Вы используете гостевой доступ (Вход)

cs101 ОП / Basics of programming ENG

  1. В начало
  2. Курсы
  3. Осенний семестр
  4. Фундаментальная информатика и ИТ
  5. cs101 ENG
  6. 1 topic. Basic constructions and loops
  7. Lesson #11. While & Repeat Loops

Lesson #11. While & Repeat Loops

Требуемые условия завершения
Открыто: Friday, 1 November 2019, 00:00

Lections

Sintax:


*************************************************************************

Example Task: To output the sequence 0 1 2 3 4

Solution:

WhileRepeat

*****************************************************************************************

Modelling while loop through repeat loop & repeat through while

While => Repeat:


Repeat => While :


*****************************************************************************************


✎

1. {0.2 points}[task-01-while-repeat.pas] Output the sequence 15 16 17 18 19 20 ... 30 (from 15 to 30). Make it twice: with while loop and with repeat loop.

2. {0.2 points}[task-02-while-repeat.pas] Output the sequence 3 5 7 9 ... 21 (from 3 to 21 with a step = 2). Make it twice: with while loop and with repeat loop.

3. {0.2 points}[task-03-while-repeat.pas] Output the sequence 20 18 16 ... 2 (from 20 downto 2 with a step = 2). Make it twice: with while loop and with repeat loop.

4. {0.2 points}[task-04-while-repeat.pas] Output the sequence 15 12 9 6 3 0 (from 15 downto 0 with a step = 3). Make it twice: with loop and with for loop. Make it twice: with while loop and with repeat loop.

5. {0.2 points}[task-05-while-repeat.pas] Output the sequence 0.1 0.3 0.5 0.7 0.9 1.1. Make it twice: with while loop and with repeat loop.

6. {0.2 points}[task-06-while-repeat.pas] Output the sequence 0.0 0.5 1.0 1.5 2.0 2.5. Make it twice: with while loop and with repeat loop.

7. {0.3 points}[task-07-while-repeat.pas] Two integers A and B are given (A < B). Output integers between A and B (including A and B themselves) in ascending order and also output the number (quantity) of these numbers. Make it twice: with while loop and with repeat loop. 

****************************************************************************************

The Infinite Loop

whilerepeat

    var x:=1;

       var x:=0;


******************************************************************************

✎

1. {0.2 points}[task-1-infinite.pas] Print the word 'Hello' using one of the infinite loops.

******************************************************************************

Sums and products in the while and repeat loops

Example task: Find the sum:

s = 11 + 13 + 15 + ... + 99
While Loop

******************************************************************************* 

✎

1.{0.3 points}[task-01-sum-while.pas] Calculate a sum of all odd 2-digit integers (11+ 13 + 15 + 17 + 19 + 21 + ... + 99). Make the task two times - with while and repeat:

Example:
'the sum of all odd 2-digits ='
>>> 2475 

2.{0.3 points}[task-02-sum-while.pas]Calculate a product of 2-digit even integers in the interval [10;30] (10 * 12 * 14 * ... * 28 * 30). Make the task two times - with while and repeat.

Example:
'the product  ='
>>> 667418624 

3.{0.3 points}[task-03-sum-while.pas] 5 real numbers are entered. The program should output their sum only once, just before the end of the program. Make the task two times - with while and repeat:

entered numbers: 4.2  7.1  3.1  2.5  8.6
 => sum = 25.5

4.{0.3 points}[task-04-sum-while.pas] 5 numbers are entered. The program should output their product (multiplication) only once, just before the end of the program. Make the task two times - with while and repeat:

entered numbers: 4  7  3  2  8
 => multiplication = 1344

******************************************************

Sequences in While loop and in Nested Loops

1.{0.4 points}[task-01-nested_loops.pas] A sequence of integers is given. The indication of completion of the sequence is entered number 0 (if 0 is entered the input of the numbers of the set is finished). The program has to print 0 in the case the sequence form a non-increasing sequence of numbers, otherwise the program has to print the number 1.

Example:

'please, enter the sequence, print 0 if you want to stop:' 
1 5 9 5 0
>>> output: 0 (non-increasing sequence)
+++++++++++++++++++++++++++++++++++++++++++++++++
'please, enter the sequence, print 0 if you want to stop:' 
1 2 5 9 11 0
>>> output: 1 (increasing sequence)
Solution 1:


Solution 2:


**********************************************************************************************

2.{1 point} [task-2-nested_loops.pas] Integer K is given (K > 0) and the set of K sequences. The indication of completion of the sequences are numbers 0 (for every sequence). The program has to output the number of the elements in every sequence and also to output the total number of the elements in all the sequences together.

Example:

'please, enter the quantity of the sequences:' 3

'input the sequence #1:'
1 5 9 5 0
>>> output: 4 elements

'input the sequence #2:'
2 5 0
>>> output: 2 elements

'input the sequence #3:'
5 7 3 0
>>> output: 3 elements

'total quantity of elements: ' 9
3.{1 point} [task-3-nested_loops.pas] Integer K is given (K > 0) and the set of K none-zero numbers are inputted (the sequences). The indication of completion of the sequences are numbers 0 (for every sequence). The program has to output the number of odd elements in every sequence and also to output the total number of the elements in all the sequences together.

Example:

'please, enter the quantity of the sequences:' 3

'input the sequence #1:'
1 5 9 4 0
>>> output: 3 odd elements

'input the sequence #2:'
2 5 0
>>> output: 1 odd element

'input the sequence #3:'
5 7 3 0
>>> output: 3 odd elements

'total quantity of elements: ' 9

4.{1 point}[task-4-nested_loops.pas] Integer N is given (N >= 1) and the set of N none-zero numbers are inputted (the sequences). The indication of completion of the sequences are numbers 0 (for every sequence). The program has to output the elements in every sequence which are less than the number from the left in the sequence.

Example:

'please, enter the quantity of the sequences:' 3

'input the sequence #1:'
1 5 3 0
>>> output: 3 

'input the sequence #2:'
2 6 0
>>> output: 0

'input the sequence #3:'
5 7 4 0
>>> output: 4 

5.{1 point}[task-5-nested_loops.pas] Integer N is given (N >= 1) and the set of N none-zero numbers are inputted (the sequences). The indication of completion of the sequences are numbers 0 (for every sequence). The program has to output minimal element in every sequence .

Example:

'please, enter the quantity of the sequences:' 3

'input the sequence #1:'
1 9 12 4 0
>>> output: 1 

'input the sequence #2:'
12  6  15  0
>>> output: 6

'input the sequence #3:'
5  -3   8   2  0
>>> output: -3 

◄ Lesson #10. Minimum or Maximum value of N numbers
Lesson #12. While & Repeat Loops: digits of a number ►
Пропустить Навигация
Навигация
  • В начало

    • Страницы сайта

      • Мои курсы

      • Теги

    • Мои курсы

    • Курсы

      • Осенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

          • Compiler Development

          • КПР

          • АЗПК

          • Frontend

          • ТеорЯП

          • Ruby Eng

          • EngCA&OS

          • CS201e

          • Компиляторы - лекции

          • CS202

          • CS211 C++ ENG

          • cs101 ENG

            • Общее

            • 1 topic. Basic constructions and loops

              • ЗаданиеLesson #1. Introduction to PascalABC.NET

              • ЗаданиеLesson #2. Integers, div and mod operators

              • ЗаданиеLesson #3. Boolean Expressions And Conditions

              • ЗаданиеLesson #4. Condition operator & branches. IF s...

              • ЗаданиеLesson #5. IF statement Part II. Max and Min

              • ЗаданиеHometask (until 6/10)

              • ЗаданиеFormatted output using WritelnFormat

              • ЗаданиеLesson #6. Chained IF statements and Case statemen...

              • ЗаданиеLesson #7. Loops

              • ЗаданиеLesson #8. For Loop

              • ЗаданиеLesson #9. Sum, Accumulators, Product and Counter....

              • ЗаданиеLesson #10. Minimum or Maximum value of N numbers

              • ЗаданиеLesson #11. While & Repeat Loops

              • ЗаданиеLesson #12. While & Repeat Loops: digits of a ...

              • ЗаданиеLesson #13. Procedures

              • ЗаданиеLesson #14. Functions

              • ЗаданиеTest Loops (control test)

            • Тема 2

            • Тема 3

            • Тема 4

            • Тема 5

            • Тема 6

            • Тема 7

            • Тема 8

            • Тема 9

            • Тема 10

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Весенний семестр

        • Прикладная математика и информатика

        • Фундаментальная информатика и ИТ

        • Математика, механика

        • Педагогическое образование

        • Магистратура

          • Разработка мобильных приложений и компьютерных игр

        • Аспирантура

        • Вечернее отделение

        • Другое

      • Воскресная компьютерная школа

        • Пользователь компьютера плюс

        • Пользователь прикладных программ

        • Программирование I ступень

        • Программирование II ступень

        • Программирование III ступень

        • Архив

      • Воскресная математическая школа

        • Олимпиадная математическая школа

        • Открытое тестирование - 2023 г.

        • Открытое тестирование - 2022 г.

        • Повышение квалификации

        • Архив

        • Доступная математика

        • ВМШ - 22

      • Государственная итоговая аттестация

      • Дополнительное образование

      • Олимпиады

      • Видеолекции

      • Разное

      • Архив курсов

Вы используете гостевой доступ (Вход)
cs101 ENG
Сводка хранения данных
Скачать мобильное приложение Яндекс.Метрика