0% found this document useful (0 votes)
5 views5 pages

Prime Number Checker Project Code

This document summarizes a computer programming project to check if a user-input number is prime or not. The project allows a user to input a number, uses a function to check if it is prime, and if not prime tells the user what numbers it is divisible by. It uses long or double data types for larger numbers, and concepts like functions, variables, loops, and arithmetic operations.

Uploaded by

shahbaz zeb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Prime Number Checker Project Code

This document summarizes a computer programming project to check if a user-input number is prime or not. The project allows a user to input a number, uses a function to check if it is prime, and if not prime tells the user what numbers it is divisible by. It uses long or double data types for larger numbers, and concepts like functions, variables, loops, and arithmetic operations.

Uploaded by

shahbaz zeb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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;

[Link]();

[Link]();

return 0;

}
OUTPUT:-

***THANK YOU***

You might also like