a)
Write a program in C to print if given
number is prime or not
Answers
Answered by
1
Answer:
#include <stdio.h>
int main() {
int n,i,flag=0;
printf("enter the number :");
scanf("%d",&n);
for (i=2;i<n;i++)
{
if(n%i ==0)
{
flag =1;
}
break;
}
if(flag == 1){
printf("it is not a prime number");
}
else
{
printf("it is a prime number");
}
return 0;
}
Explanation:
OUTPUT
/* enter the number :5
it is a prime number */
Similar questions