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
What are the types of type specifiers?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
Write a program to print ASCII code for a given digit.
What is a structure in c language. how to initialise a structure in c?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What are enumerated types?
What does double pointer mean in c?
How do I create a directory? How do I remove a directory (and its contents)?
Why is structure important for a child?
Is boolean a datatype in c?
What does d mean?
Explain how can you determine the size of an allocated portion of memory?
What is the difference between procedural and declarative language?
Write program to remove duplicate in an array?