Expand|Select|Wrap|Line Numbers
- #include<iostream.h>
- #include<iomanip.h>
- class test
- {
- public:
- void store( int);
- int checkprime();
- void print();
- private:
- int num;
- };
- void test::store(int value)
- { while(value != 0)
- {
- num= value;
- }
- };
- int test::checkprime()
- {
- int counter, i, j, size, value;
- for(i = 2; i < size; i++)
- {
- for(j = 2 * i;x j < size; j += 1)
- if( counter % 12 == 0 )
- cout << '\n';
- cout << endl;
- cout << "Enter a value: ";
- cin >> value;
- while( value != -999 )
- {
- if( counter == value )
- cout << value << "This is a prime number\n";
- else
- cout << value << "This is not a prime number\n";
- cout << "Enter a value: ";
- cin >> value;
- return 0;
- int result,
- divisor = num/2;
- for ( divisor; divisor > 1; divisor--)
- {
- result = num % divisor;
- //Uncomment the next line to output the
- // divisor and the remainder.
- //cout<< divisor << " \t" &l
- // t;< res << endl;
- // if( result == 0 )
- // {
- // cout<< input << " is not prime!" << endl << endl;
- // break;
- if( result != 0 )
- return num ;
- }
- };
- void test::print()
- {
- int value, num;
- cout << num<< " ";
- cout << value << " ";
- };
- int main()
- {
- int value, num;
- test j;
- cout<< "Enter a number to check if it is a prime number"<<endl;
- cin >> value;
- j.store( value);
- j.checkprime();
- j.print();
- return 0;
- }
1. Create a class test that will have the following features:-
Must have a private attribute that stores an integer.
A public method call store that returns no value
A public method checkprime that returns an integer
A public method print that returns no value.
2.Use the class above to create a program that will accept an indefinite number of integers and print those that are prime numbers.