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
Explain what is the benefit of using const for declaring constants?
What is a floating point in c?
Can static variables be declared in a header file?
What’s the special use of UNIONS?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What is a char c?
C language questions for civil engineering
What is a void pointer in c?
What is 2c dna?
Can include files be nested? How many levels deep can include files be nested?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
When is the “void” keyword used in a function?
There seem to be a few missing operators ..
Explain void pointer?
difference between native and cross compilers