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 |
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }
Who could write how to find a prime number in dynamic array?
C statement to copy a string without using loop and library function..
typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
main() { int i=5; printf("%d",++i++); }
Printf can be implemented by using __________ list.
main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }