Computer Science, asked by 508183, 5 months ago

Write a program to print numbers between m and n , where m= starting number and n= ending number which should be inputted by the user

Answers

Answered by allysia
1

Language:

Python

Program:

n,m =int(input()),int(input())

for i in range(n ,m+1):

    print(i)

Explanation:

  • Take input m and n making sure the datatype is set to int.
  • use loop to print the number (I used for loop)
  • for limit range(a,b) only a to b-1 numbers are returned.
Answered by vinod04jangid
0

Answer:

Run a loop from m to n and print the value of m for each iteration. Decrement the value of m by n after each iteration.

Explanation:

import java.util.Scanner;

public class KboatPerfectSquare

{

   public static void main(String args[]) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter m: ");

       int m = in.nextInt();

       System.out.print("Enter n: ");

       int n = in.nextInt();

       

       if (m < n && m > 0 && n > 0) {

           for (int i = m; i <= n; i++) {

               System.out.println("Number = " + i);

               double sroot = Math.sqrt(i);

               if (sroot == Math.floor(sroot))

                   System.out.println(i + " is a perfect square");    

           }

       }

       else {

           System.out.println("Invalid input");

       }

   }

}

#spj2

Similar questions