write a progra in c++ using class & object to find out
wheather a given no. is prim or not.

Answer Posted / rakesh ranjan

#include<conio.h>
void main()
{
int a,i;
printf("enter the number ");
scanf("%d",&a);
for(i=2;i<a;i++)
if(a%i==0)
{
printf("number is not Prime");
break;
}
if(i==a)
printf("Prime number");
getch();
}

Is This Answer Correct ?    16 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Whats is abstraction in oops?

699


How do you achieve runtime polymorphism?

645


What is the difference between static polymorphism and dynamic polymorphism?

718


Can an interface inherit a class?

644


What is oops?what is its use in software engineering?

630






How many human genes are polymorphic?

658


They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?

1491


What is inheritance and how many types of inheritance?

705


What is a class in oop?

676


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4340


what is difference between class template and template class?

2244


Can you inherit a private class?

732


What are the 3 pillars of oop?

724


Which language is not a true object oriented programming language?

746


What are two types of polymorphism?

691