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 |
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }
Is this code legal? int *ptr; ptr = (int *) 0x400;
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }
How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?
main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }
void main() { int i=5; printf("%d",i++ + ++i); }
how can i cast a char type array to an int type array
main() { printf("%d", out); } int out=100;
What is "far" and "near" pointers in "c"...?
Write a program to model an exploding firecracker in the xy plane using a particle system
main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }