write the program for prime numbers?
Answer Posted / varun raj s p
#include<stdio.h>
int main()
{
int n, i = 3, count, c;
printf("Enter the number of prime numbers required\n");
scanf("%d",&n);
if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which header file should you include if you are to develop a function which can accept variable number of arguments?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
what is the diffrenet bettwen HTTP and internet protocol
Write a C program to count the number of email on text
What is file in c language?
Explain what is wrong with this program statement?
Explain the use of fflush() function?
Calculate 1*2*3*____*n using recursive function??
what does static variable mean?
Why do we need volatile in c?
What is sizeof array?
Implement bit Array in C.
What is a function in c?
How can you find out how much memory is available?
What is an expression?