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
Where are c variables stored in memory?
What are the __date__ and __time__ preprocessor commands?
What do you mean by recursion in c?
When should we use pointers in a c program?
What does %d do in c?
Can you tell me how to check whether a linked list is circular?
find out largest elemant of diagonalmatrix
Why is c so powerful?
What is the difference between int main and void main in c?
How do I use void main?
Write a c program to demonstrate character and string constants?
Why c is procedure oriented?
Explain how can I prevent another program from modifying part of a file that I am modifying?
What is the translation phases used in c language?
What are the 5 types of organizational structures?