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 is difference between Structure and Unions?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Why doesn't C support function overloading?
What is #define in c?
What is this infamous null pointer, anyway?
When is a void pointer used?
Explain modulus operator. What are the restrictions of a modulus operator?
What are the back slash character constants or escape sequence charactersavailable in c?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
What are reserved words with a programming language?
Explain #pragma statements.
What is bubble sort in c?
Explain the priority queues?
Write a program for Overriding.
Explain how can I make sure that my program is the only one accessing a file?