Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
  • Home
  • Notes
    • Online Courses
      • 12th Class
      • 11th Class
      • 10th Class
      • 9th Class
  • Jobs
    • PPSC Jobs
    • SPSC Jobs
    • Punjab Police Jobs
  • Education News
  • E-Books
    • Punjab Text Book (PTB)
  • Model Papers
  • Results
  • Admissions
  • Colleges
  • More
    • Paper Schemes
    • Date Sheets
    • Guess Papers
    • Roll No Slips
Facebook Twitter
Trending
  • NADRA Islamabad Announced Latest April Jobs 2024
  • TEVTA Sargodha Announced Instructor / Clerk Jobs 2024
  • BPSC Announced Latest Jobs Through Advertisement no. 03/2024
  • All Subjects 12th Class Paper Scheme 2024 | Punjab Board
  • 12th Class Computer Science Paper Scheme 2024 Punjab Board
  • 9th Class Pakistan Studies Guess Papers 2024 Punjab Board
  • 12th Class Biology Paper Pairing Scheme 2024 Punjab Board
  • Physics 12th Class Paper Scheme 2024 Punjab Board
Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
  • Home
  • Notes
    • Online Courses
      • 12th Class
      • 11th Class
      • 10th Class
      • 9th Class
  • Jobs
    • PPSC Jobs
    • SPSC Jobs
    • Punjab Police Jobs
  • Education News
  • E-Books
    • Punjab Text Book (PTB)
  • Model Papers
  • Results
  • Admissions
  • Colleges
  • More
    • Paper Schemes
    • Date Sheets
    • Guess Papers
    • Roll No Slips
Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
Home » Computer Science » C Language » C Programs » [C/C++] Program to Find Prime Number
C Language

[C/C++] Program to Find Prime Number

September 25, 2015Updated:September 13, 20182 Comments1 Min Read
WhatsApp Facebook Twitter Pinterest LinkedIn Tumblr Email

What is a Prime Number?
” A Natural number greater than 1 which has only two divisor 1 and itself is called prime number “.
For Example:
5 is prime, because it has only two divisors 1 and itself.

C Code

#include <stdio.h>
#include <conio.h>

void main()
{
	int num,count=0;
	printf("Enter Number: ");
	scanf("%d", num);
	for(int i=1;i<=num;i++)
	{
		if(num%i==0)
		{	count++;	}
	}
	if(count==2)
	{	printf("%d is a Prime Number.\n", num);	}
	else
	{	printf("%d is Not a Prime Number.\n", num);	}
	
	getch();
	return 0;
}

C++ Code

#include <iostream>
#include <conio.h>

int main()
{
	using namespace std;
	int num,count=0;
	cout << "Enter Number: "; cin >> num;
	for(int i=1;i<=num;i++)
	{
		if(num%i==0)
		{	count++;	}
	}
	if(count==2)
	{	cout<< num << " is a Prime Number.\n";	}
	else
	{	cout<< num << " is Not a Prime Number.\n";	}
	
	getch();
	return 0;
}

Output:

program-to-find-prime-number

Other Related Search Terms

  1. Code For Prime Number In C++
  2. Code For Prime Number In C
  3. C++ Programs to find Prime number
  4. C Programs to find Prime number
  5. Find all Prime numbers
  6. Check number is prime or not c/c++

c programs computer science 2nd year cpp programs Online Course
Share. WhatsApp Facebook Twitter Pinterest LinkedIn Tumblr Email
Khurram Farooq
  • Website
  • Facebook
  • Twitter

I'm a full-stack developer, specializing in the PHP, JS, Wordpress, MEAN Stack, MERN Stack & Django. I hold a high standard of quality in everything that I do.

Related Posts

How to do Exponents in Java – 3 Different Methods

January 12, 2020

Different Types of Processors And Their Features

January 12, 2020

Biology 1st Year Guess Paper 2018 Punjab Board

May 28, 2018

2 Comments

  1. Asad Ch on September 17, 2017 5:20 pm

    Thanks for your program.Its working perfectly

    Reply
    • sunny on September 18, 2017 6:11 pm

      Ty for your appreciation :-)
      Share with others as well.

      Reply

Leave A Reply Cancel Reply

SEARCH
ADVERTISEMENT
STAY WITH US
  • Facebook
  • Twitter
  • Instagram
LATEST JOBS

NADRA Islamabad Announced Latest April Jobs 2024

April 4, 2024

TEVTA Sargodha Announced Instructor / Clerk Jobs 2024

April 4, 2024

BPSC Announced Latest Jobs Through Advertisement no. 03/2024

April 4, 2024
LATEST NOTES

All Subjects 12th Class Paper Scheme 2024 | Punjab Board

April 4, 2024

12th Class Computer Science Paper Scheme 2024 Punjab Board

April 4, 2024

9th Class Pakistan Studies Guess Papers 2024 Punjab Board

April 4, 2024
RECENT POSTS

NADRA Islamabad Announced Latest April Jobs 2024

April 4, 2024

TEVTA Sargodha Announced Instructor / Clerk Jobs 2024

April 4, 2024

BPSC Announced Latest Jobs Through Advertisement no. 03/2024

April 4, 2024

All Subjects 12th Class Paper Scheme 2024 | Punjab Board

April 4, 2024
TRENDING THIS WEEK

Cambridge CAIE Announced Revised A-Level Exam Schedule 2023

May 23, 2023

Top 7 CSS Academies in Pakistan | List Of Best CSS Academies

October 23, 2019

BISE Lahore Board HSSC-II (12th Class) Result Gazette 2022

October 20, 2022
ABOUT US
ABOUT US

Notes, Guess Papers, Old Papers, Jobs, Admissions, Results, Datasheets and everything else that falls into the wide world of education & careers. For any assist and query please contact us.

Home · About Us · Team · Contact · Advertise · DMCA Policy · Cookies Policy · Privacy Policy
© 2013-2025 Powered By FScOnline - Made with ♥ for the students of Pakistan.

Type above and press Enter to search. Press Esc to cancel.

Go to mobile version
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy policy