SlideShare a Scribd company logo
Sitesbay.com
Prime Number Program
Prime Number Program in C
Hitesh Kumar
SITESBAY.COM
Sitesbay.com
Prime Number Program in C
This is very simple and easy to write Prime Number Program in C. You need for loop and
if..else statements.
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,t=0,flag=0;
clrscr();
printf("Enter any Number:");
scanf("%d",&num);
t=num/2;
for(i=2; i<=t; i++)
{
if(num%i==0)
{
printf("Number is not prime");
flag=1;
break;
}
}
if(flag==0)
printf("Number is prime");
getch();
}
Sitesbay.com
Output:
Enter any Number: 30
Number is not prime
Enter any Number: 53
Number is prime

More Related Content

What's hot

Arrays in c
Arrays in cArrays in c
Arrays in c
vampugani
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
BUBT
 
Recursion
RecursionRecursion
Radix Sort
Radix SortRadix Sort
Radix Sort
Faiza Saleem
 
Binary codes
Binary codesBinary codes
Binary codes
GargiKhanna1
 
Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++
Ashok Raj
 
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational CircuitsCOMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
Vanitha Chandru
 
Strings
StringsStrings
Strings
Imad Ali
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
shahzad ali
 
compliments
 compliments compliments
compliments
Unsa Shakir
 
Function in C
Function in CFunction in C
Function in C
Dr. Abhineet Anand
 
Pseudo code
Pseudo codePseudo code
Pseudo code
Arindam Ghosh
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
Aakash Singh
 
Digital logic Gates of Computer Science
Digital logic Gates of Computer ScienceDigital logic Gates of Computer Science
Digital logic Gates of Computer Science
Anil Kumar Prajapati
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
DevoAjit Gupta
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
Ahmed Khateeb
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
Martin McBride
 
Character set of c
Character set of cCharacter set of c
Character set of c
Chandrapriya Rediex
 
C functions
C functionsC functions
Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)
Digvijaysinh Gohil
 

What's hot (20)

Arrays in c
Arrays in cArrays in c
Arrays in c
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
Recursion
RecursionRecursion
Recursion
 
Radix Sort
Radix SortRadix Sort
Radix Sort
 
Binary codes
Binary codesBinary codes
Binary codes
 
Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++
 
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational CircuitsCOMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
COMPUTER ORGANIZATION - Logic gates, Boolean Algebra, Combinational Circuits
 
Strings
StringsStrings
Strings
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
 
compliments
 compliments compliments
compliments
 
Function in C
Function in CFunction in C
Function in C
 
Pseudo code
Pseudo codePseudo code
Pseudo code
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
Digital logic Gates of Computer Science
Digital logic Gates of Computer ScienceDigital logic Gates of Computer Science
Digital logic Gates of Computer Science
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
C functions
C functionsC functions
C functions
 
Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)
 

More from Hitesh Kumar

Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
HTML Interview Questions | Basic Html Interview Questions
HTML Interview Questions | Basic Html Interview QuestionsHTML Interview Questions | Basic Html Interview Questions
HTML Interview Questions | Basic Html Interview Questions
Hitesh Kumar
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
Hitesh Kumar
 
CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience
Hitesh Kumar
 
Factorial Program in C
Factorial Program in CFactorial Program in C
Factorial Program in C
Hitesh Kumar
 
Top JSON Interview Questions for Freshers
Top JSON Interview Questions for FreshersTop JSON Interview Questions for Freshers
Top JSON Interview Questions for Freshers
Hitesh Kumar
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of Example
Hitesh Kumar
 
Fibonacci series c++
Fibonacci series c++Fibonacci series c++
Fibonacci series c++
Hitesh Kumar
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Interface in java
Interface in javaInterface in java
Interface in java
Hitesh Kumar
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++
Hitesh Kumar
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
Hitesh Kumar
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Hitesh Kumar
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Ternary operator
Ternary operatorTernary operator
Ternary operator
Hitesh Kumar
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
Hitesh Kumar
 
Main method in java
Main method in javaMain method in java
Main method in java
Hitesh Kumar
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 

More from Hitesh Kumar (20)

Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
 
HTML Interview Questions | Basic Html Interview Questions
HTML Interview Questions | Basic Html Interview QuestionsHTML Interview Questions | Basic Html Interview Questions
HTML Interview Questions | Basic Html Interview Questions
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
 
CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience
 
Factorial Program in C
Factorial Program in CFactorial Program in C
Factorial Program in C
 
Top JSON Interview Questions for Freshers
Top JSON Interview Questions for FreshersTop JSON Interview Questions for Freshers
Top JSON Interview Questions for Freshers
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of Example
 
Fibonacci series c++
Fibonacci series c++Fibonacci series c++
Fibonacci series c++
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Ternary operator
Ternary operatorTernary operator
Ternary operator
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
 
Main method in java
Main method in javaMain method in java
Main method in java
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 

Recently uploaded

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 

Recently uploaded (20)

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 

Prime number program in C

  • 1. Sitesbay.com Prime Number Program Prime Number Program in C Hitesh Kumar SITESBAY.COM
  • 2. Sitesbay.com Prime Number Program in C This is very simple and easy to write Prime Number Program in C. You need for loop and if..else statements. #include<stdio.h> #include<conio.h> void main() { int num,i,t=0,flag=0; clrscr(); printf("Enter any Number:"); scanf("%d",&num); t=num/2; for(i=2; i<=t; i++) { if(num%i==0) { printf("Number is not prime"); flag=1; break; } } if(flag==0) printf("Number is prime"); getch(); }
  • 3. Sitesbay.com Output: Enter any Number: 30 Number is not prime Enter any Number: 53 Number is prime