Write a program to find all numbers which are perfect square in an integer array of size 15
Answers
Answered by
50
Answer:
Assuming it's Java Programming...
package Programmer;
import java.util.*;
public class ArrPerfect{
public static void main (String ar[]){
Scanner sc=new Scanner (System.in);
System.out.println("Enter a number");
int arr[]=new int[15];
for(int I=1;I<15;I++){
arr[I]=sc.nextInt();
}
for(int I=1;I<15;I++){
int p=(int)(Math.sqrt(arr[I]));
if((p*p)==arr[I])
System.out.println("Perfect Square:"+arr[I]);
}
}
}
_________
Variable Description:-
- arr :- to store numbers in an array
- I:- loop variable
- p:- local variable to store square root of a number in integer form
__________
•Output Attached.
Attachments:
Similar questions
Computer Science,
1 month ago