write a progra in c++ using class & object to find out
wheather a given no. is prim or not.
Answers were Sorted based on User's Feedback
Answer / ***..$indhu..***
#include<iostream.h>
#include<conio.h>
class prime
{
int n,i;
public:
void giveno(int);
void no_prime();
};
void prime::giveno(int a)
{
n=a;
}
void prime::no_prime()
{
i=2;
if(i<=n-1)
{
if(n%i==0)
{
cout<<endl<<"not prime no";
else
cout<<endl<<"prime no";
break;
}
if(n==i)
{
cout<<endl<<"prime no";
}
}
}
int main()
{
prime p1;
p1.giveno(5);
p1.no_prime();
return 0;
}
| Is This Answer Correct ? | 33 Yes | 10 No |
Answer / 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 |
what is an qt4 interface?
INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
i have to create a view in SQL as like in ORACLE DATA EXPRESS EDITION
Why is oop better than procedural?
What are objects in oop?
difference between structure and union.
What are the four main oops concepts?
What makes a language oop?
What is encapsulation in simple terms?
Write a program in c++ to read two floating point numbers and find their sum and average.
What is Method overloading?