write the program for prime numbers?
Answer Posted / nitesh sanwal
#include<stdio.h>
#include<math.h>
void main()
{
int n,i,prime=1;
printf("input the numbers");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
if(n%i==0)
{
prime=0;
break;
}
if(prime)
printf("%d is a prime number",n);
else
printf("%d is a not a prime number",n);
}
Is This Answer Correct ? | 6 Yes | 3 No |
Post New Answer View All Answers
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What is const keyword in c?
What is difference between %d and %i in c?
hi any body pls give me company name interview conduct "c" language only
What is the description for syntax errors?
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
What are the types of pointers?
how to write a c program to print list of fruits in alpabetical order?
write a c program for swapping two strings using pointer
What is realloc in c?
What are the rules for the identifier?
Write a function that will take in a phone number and output all possible alphabetical combinations
What are the valid places to have keyword “break”?