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 |
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
What is data _null_? ,Explain with code when u need to use it in data step programming ?
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
main() { char a[4]="HELLO"; printf("%s",a); }
Question: We would like to design and implement a programming solution to the reader-writer problem using semaphores in C language under UNIX. We assume that we have three readers and two writers processes that would run concurrently. A writer is to update (write) into one memory location (let’s say a variable of type integer named temp initialized to 0). In the other hand, a reader is to read the content of temp and display its content on the screen in a formatted output. One writer can access the shared data exclusively without the presence of other writer or any reader, whereas, a reader may access the shared memory for reading with the presence of other readers (but not writers).
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
Write a program to receive an integer and find its octal equivalent?
main() { static int var = 5; printf("%d ",var--); if(var) main(); }
Write a program that find and print how many odd numbers in a binary tree
main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above
main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above