-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog2.java
More file actions
39 lines (32 loc) · 750 Bytes
/
prog2.java
File metadata and controls
39 lines (32 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Wipro(level-basic)
Given two given numbers a and b where 1<=a<=b, find the number of perfect squares between a and b (a and b inclusive).
Input:
Each line of test case contain numbers 'a' and 'b' separated by a single space.
Output:
Number of perfect squares are displayed.
Example:
Input:
1 1000
Output:
31
*/
import java.util.Scanner;
public class prog2
{
public static void main(String[] args) {
int count=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value of a and b");
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println("Output:");
for(int i=a;i<=b;i++){
for(int j=1;j<=b;j++){
if(j*j==i){
count++;
}
}
}
System.out.println(count);
}
}