The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
See Our team
Wondering how we keep quality?
Got unsolved questions?

PROGRAMMINGMACHINE-LEARNING-->View question

## Write a program to check whether the given number is prime or not?

its about Write a program to check whether the given number is prime or not

Taged users:

Likes:
Be first to like this question

Dislikes:
Be first to dislike this question
C program
#include <stdio.h>
int main()
{
int i, num, p = 0;
scanf("%d", &num);
for(i=1; i<=num; i++)
{
if(num%i==0)
{
p++;
}
}
if(p==2)
{
printf("Entered number is %d "\
"and it is a prime number.",num);
}
else
{
printf("Entered number is %d "\
"and it is not a prime number.",num);
}
}

Likes:
|Ananth

Dislikes:
Be first to dislike this answer

### Watch more videos from this user Here

Learn how to upload a video and start earning here

# Python program to check if
# given number is prime or not

num = 11

# If given number is greater than 1
if num > 1:

# Iterate from 2 to n / 2
for i in range(2, num//2):

# If num is divisible by any number between
# 2 and n / 2, it is not prime
if (num % i) == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")

else:
print(num, "is not a prime number")

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer

### Watch more videos from this user Here

Learn how to upload a video and start earning here

Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.