write the program for prime numbers?
Answer Posted / pawan kumar
#include<stdio.h>
int main(){
int num,i,count=0;
printf("Enter a number: ");
scanf("%d",&num);
for(i=2;i<=num/2;i++){
if(num%i==0){
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d is a prime number",num);
else
printf("%d is not a prime number",num);
return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Which is best book for data structures in c?
What is the use of void pointer and null pointer in c language?
Explain how do you print an address?
Write a program to know whether the input number is an armstrong number.
State two uses of pointers in C?
What is the 'named constructor idiom'?
Why is c called a structured programming language?
How many types of functions are there in c?
What is a built-in function in C?
Here is a neat trick for checking whether two strings are equal
What is the purpose of ftell?
What does typedef struct mean?
What is f'n in math?
What are the different types of errors?
What is pointer to pointer in c with example?