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
Can an array be an Ivalue?
c program to compute AREA under integral
What is c method?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
How can I pad a string to a known length?
Why is main function so important?
Explain what are multibyte characters?
What's the difference between constant char *p and char * constant p?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
What is the explanation for modular programming?
What do you know about the use of bit field?
What is floating point constants?
Is Exception handling possible in c language?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);