SlideShare a Scribd company logo
2
Most read
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 (20)

PPTX
Data types in C language
kashyap399
 
PPTX
Structure & union
lalithambiga kamaraj
 
PPTX
Unit 2. Elements of C
Ashim Lamichhane
 
PPTX
Introduction to Array ppt
sandhya yadav
 
PPTX
C Token’s
Tarun Sharma
 
PPT
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
PPTX
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
Muhammad Hammad Waseem
 
PPTX
Programming in c Arrays
janani thirupathi
 
PPTX
Algorithm and flowchart
Rabin BK
 
PPTX
Typecasting in c
Tushar Shende
 
PPTX
Unit 3. Input and Output
Ashim Lamichhane
 
PPTX
C Programming Unit-1
Vikram Nandini
 
PDF
Character set in c
polast
 
PPTX
C tokens
Manu1325
 
PPT
Constants in C Programming
programming9
 
PPT
Counting Sort and Radix Sort Algorithms
Sarvesh Rawat
 
PPTX
Conditional statement c++
amber chaudary
 
PPTX
Input output statement in C
Muthuganesh S
 
PPT
constants, variables and datatypes in C
Sahithi Naraparaju
 
Data types in C language
kashyap399
 
Structure & union
lalithambiga kamaraj
 
Unit 2. Elements of C
Ashim Lamichhane
 
Introduction to Array ppt
sandhya yadav
 
C Token’s
Tarun Sharma
 
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
Muhammad Hammad Waseem
 
Programming in c Arrays
janani thirupathi
 
Algorithm and flowchart
Rabin BK
 
Typecasting in c
Tushar Shende
 
Unit 3. Input and Output
Ashim Lamichhane
 
C Programming Unit-1
Vikram Nandini
 
Character set in c
polast
 
C tokens
Manu1325
 
Constants in C Programming
programming9
 
Counting Sort and Radix Sort Algorithms
Sarvesh Rawat
 
Conditional statement c++
amber chaudary
 
Input output statement in C
Muthuganesh S
 
constants, variables and datatypes in C
Sahithi Naraparaju
 

More from Hitesh Kumar (20)

DOCX
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
PDF
HTML Interview Questions | Basic Html Interview Questions
Hitesh Kumar
 
PDF
Fibonacci Series Program in C++
Hitesh Kumar
 
PDF
CSS Interview Questions for Fresher and Experience
Hitesh Kumar
 
PDF
Factorial Program in C
Hitesh Kumar
 
PDF
Top JSON Interview Questions for Freshers
Hitesh Kumar
 
PDF
Queue in C, Queue Real Life of Example
Hitesh Kumar
 
PDF
Fibonacci series c++
Hitesh Kumar
 
PPTX
Super keyword in java
Hitesh Kumar
 
DOCX
Interface in java
Hitesh Kumar
 
DOCX
Encapsulation in C++
Hitesh Kumar
 
DOCX
Abstract class in java
Hitesh Kumar
 
PPTX
Super keyword in java
Hitesh Kumar
 
PPTX
Final keyword in java
Hitesh Kumar
 
PPTX
Constructor in java
Hitesh Kumar
 
PPTX
Super keyword in java
Hitesh Kumar
 
PPTX
Ternary operator
Hitesh Kumar
 
PPT
File handling in C++
Hitesh Kumar
 
PPTX
Main method in java
Hitesh Kumar
 
PPTX
This keyword in java
Hitesh Kumar
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
HTML Interview Questions | Basic Html Interview Questions
Hitesh Kumar
 
Fibonacci Series Program in C++
Hitesh Kumar
 
CSS Interview Questions for Fresher and Experience
Hitesh Kumar
 
Factorial Program in C
Hitesh Kumar
 
Top JSON Interview Questions for Freshers
Hitesh Kumar
 
Queue in C, Queue Real Life of Example
Hitesh Kumar
 
Fibonacci series c++
Hitesh Kumar
 
Super keyword in java
Hitesh Kumar
 
Interface in java
Hitesh Kumar
 
Encapsulation in C++
Hitesh Kumar
 
Abstract class in java
Hitesh Kumar
 
Super keyword in java
Hitesh Kumar
 
Final keyword in java
Hitesh Kumar
 
Constructor in java
Hitesh Kumar
 
Super keyword in java
Hitesh Kumar
 
Ternary operator
Hitesh Kumar
 
File handling in C++
Hitesh Kumar
 
Main method in java
Hitesh Kumar
 
This keyword in java
Hitesh Kumar
 
Ad

Recently uploaded (20)

PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PDF
John Keats introduction and list of his important works
vatsalacpr
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Basics and rules of probability with real-life uses
ravatkaran694
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Virus sequence retrieval from NCBI database
yamunaK13
 
John Keats introduction and list of his important works
vatsalacpr
 
Ad

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