Program to find greatest prime number in n numbers?
Answer Posted / rajani nagandla
1.Read n
2.lets take variables of type int (i=1,j=1,temp=0,count=0);
3. for (;i<n;i++){
count=0;
while(j<=i){
if((i%j)==0){
count+=1;
j++;
if(count>2)break;
}
}
if(count==2)
temp=i;
}
4.the value in temp after for loop execution will be the
Greatest Prime Number
| Is This Answer Correct ? | 6 Yes | 5 No |
Post New Answer View All Answers
Which programming language is best in future?
What is Major and importance difference between for and foreach loop ?
What is abstraction in java?
What are data types in oop?
What is udp in java?
Give any two differences between C++ and java.
Compare overloading and overriding?
Explain what access modifiers can be used for variables?
Is java based on c?
What is entry set in java?
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?
Explain static nested classes ?
How variables are declared?
Why is boolean important?
Name few java 8 annotations ?