You are on page 1of 5

COMPUTER PROGRAMMING PROJECT

PREPARED BY:-

SHAHBAZ ZEB(18CS2996).

DATE OF PROJRCT:-22/03/2019

DATE OF SUMISSION:-05/04/2019

SUBMITTED TO:-

GURJEETPAL SIR
Question:-
Create a mini project that will:

a. Allow a user to input a number.


b. Allow the user to see if the number is prime or not.
c. If te numer is not prime,tell the user what number it is divisible by.
d. Use a function to process whether or not the value is prime(this data will be used in
the future challenge).
e. Use the double or long for increased number length.

CONCEPT USED:-

Functions,variables,loops,arithmetic functions,breaks.

Solution:

#include<iostream>

#include<stdio.h>

using namespace std;

class number

long int n;

int i,c = 0;

public:

void input()

cout<<"Enter the number to be checked: ";

cin>>n;

void prime()

if (n==0)
{

cout << "\n" << n << " is not prime";

else

for(i=2; i < n; i++)

if (n%i == 0)

c++;

if (c>1)

cout << "\n" << n << " is not prime."<<endl;

divisor();

else

cout << "\n" << n << " is prime.";

void divisor()

int a;

cout<<"The number is divisible by :";


for(a=1;a<=n;a++)

if(n%a==0)

cout<<a<<endl;

};

int main()

number n1;

n1.input();

n1.prime();

return 0;

}
OUTPUT:-

***THANK YOU***

You might also like