
составить программуввести с клавиатуры 2 целых числа m и n >0 если m делится на n или наоборот,
то вывести единицу, иначе любое другое число

Ответы на вопрос

uses crt;
var m,n:longint;
begin
read(m,n);
if (m mod n=0) or (n mod m=0) then writeln(1)
else writeln(2);
end.



Program to Check if Two Numbers are Divisible
Here is a program written in Java that prompts the user to enter two positive integers, `m` and `n`, and checks if `m` is divisible by `n` or vice versa. If `m` is divisible by `n` or vice versa, the program will output `1`. Otherwise, it will output any other number.
```java import java.util.Scanner;
public class DivisibilityCheck { public static void main(String[] args) { Scanner input = new Scanner(System.in);
System.out.print("Enter the first number (m): "); int m = input.nextInt();
System.out.print("Enter the second number (n): "); int n = input.nextInt();
if (m % n == 0 || n % m == 0) { System.out.println("1"); } else { System.out.println("Any other number"); } } } ```
To use this program, you need to have Java installed on your computer. You can compile and run the program using a Java development environment or by using the command line. After running the program, you will be prompted to enter the values for `m` and `n`. The program will then check if `m` is divisible by `n` or vice versa and output the result accordingly.
Please note that this program assumes that the user will enter valid positive integers for `m` and `n`. If the user enters invalid input, such as non-numeric characters or negative numbers, the program may produce unexpected results or throw an error. It is always a good practice to include input validation in your programs to handle such cases.
I hope this helps! Let me know if you have any further questions.


Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili