Toggle navigation
Log in
Sign Up
Log in
Sign Up
Appium
C
C#
C++
Docker
Go
Informatica
Java
JavaScript
Kafka
Numpy
Oracle
Pandas
PHP
Py Spark
Python
R
React Native
Scipy
SFTP
Tableau
Teradata
TGMC
UNIX
Forget_Code.Models.CategoryViewModel
Add a new snippet
Algorithms
13
Applications
5
Arithmetic Operations
2
Array
8
Basics
27
Compiler Design
1
Control Statements
4
Conversion Functions
1
Data Structures
12
Data Type
1
Date Functions
1
File
36
Keywords
1
Loops
1
Math Functions
30
Math Snippets
43
Memory Management
3
Misc
4
Networking
4
Operators
6
Pointers
17
String Functions
30
String Snippets
29
System Software
10
Utility Snippets
1
Choose Category
C program to find the Prime Number in C
Forget Code
C
C program to find the Prime Number
#include <stdio.h>
int main()
{
int n, r = 0 ;
printf("Enter number to find the Prime Number\n");
printf("Enter num : ");
scanf("%d",&n);
for (int i=2; i<=n/2; i++)
{
if (n%i == 0)
{
r = 1;
break ;
}
}
if (n == 1)
printf("1 is neither prime nor composite.\n");
else
{
if (r == 0)
printf("%d is a Prime number.\n",n);
else
printf("%d is Not a Prime number.\n",n);
}
return 0;
}
Contribute to Forget Code, help others.
Add snippet