Who could write how to find a prime number in dynamic array?
Answer / basavaraj
class Demo{
static boolean prime(int n){
int c=0;
for(int i=0;i<n;i++){
if(n%i==0){
c++;
}
}
if(c==2){
return true;
}else{
return false;
}
public static void main(String[] args){
int[] arr={2,5,7,6,8,11,14,13,50};
for(int i=0;i<arr.length;i++){
if(prime(arr[i]){
System.out.println(arr[i]+" ");
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
write a program in c language to get the value of arroy keys pressed and display the message which arrow key is pressed?
How to reverse a String without using C functions ?
33 Answers Matrix, TCS, Wipro,
how can i cast a char type array to an int type array
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
write a c-program to find gcd using recursive functions
program to find the roots of a quadratic equation
14 Answers College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,
print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!
35 Answers Tata Elxsi, TCS, VI eTrans,
Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..
Is it possible to print a name without using commas, double quotes,semi-colons?
main() { printf("%d", out); } int out=100;
main() { 41printf("%p",main); }8
write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30