Skip to content

Latest commit

 

History

History
36 lines (33 loc) · 3.3 KB

File metadata and controls

36 lines (33 loc) · 3.3 KB

IsNumberDividesBy9. C++ Tutorials. Embarcadero Rad Studio IDE. Simple Input/Output. Algorithms. Console application. A console application project written in the C++ programming language and implemented in the Embarcadero Rad Studio IDE integrated environment. The Win32 Console system provides simple input/output. Determining the sum of digits in a number entered from the keyboard. Answer to the question whether a given number is divisible by 9. The program does the following:

  1. Prompts the user for an integer.
  2. Sets the sum of digits variable to zero.
  3. Creates a temporary variable with an initial a positive value equal in magnitude to the number entered from the keyboard.
  4. The loop with precondition is executed: a) The value of the temporary variable is compared to zero. If its value is greater than zero, the loop continues executing; otherwise, it terminates. (Go to step 5) b) The sum of digits variable is incremented by modulo to 10. c) The temporary variable is divisible by 10.
  5. It is checked whether the resulting sum of the digits of the number is divisible by 9.
  6. The entered number and the sum of its digits are displayed on the screen.
  7. The answer to the question whether the given number is divisible by 9 is displayed on the screen.

IsNumberDividesBy3. ИС Rad Studio. Занятия по C++. Простой Ввод/Вывод. Алгоритмы. Платформа Windows. Консольное приложение. Проект консольного приложения написан на языке программирования C++ и реализован в интегрированной среде Embarcadero Rad Studio. Платформа Windows. Простой ввод-вывод. Определение суммы цифр в числе, введённом с клавиатуры. Ответ на вопрос делится ли данное число на 9. Данная программа делает следующее:

  1. Запрашивает у пользователя ввод целого числа.
  2. Устанавливает переменную суммы цифр в значение равное нулю.
  3. Создаёт временную переменную с первоначальным положительным значением равным по модулю числу введённому с клавиатуры.
  4. Выполняется цикл с предусловием: a) Значение переменной сравнивается с нулём. Если оно больше нуля, цикл продолжает выполняться, в противном случае завершается (Переход к пункту 5). b) Сумма цифр увеличивается на остаток от деления значения временной переменной на 10. c) Времменая переменная делится на 10
  5. Проверяется делится ли полученная сумма цифр числа на 9.
  6. На экран выводится введённое число и сумма его цифр.
  7. На экран выводится ответ на вопрос делится ли данное число на 9.