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
What are actual arguments?
What is a memory leak? How to avoid it?
Write a Program to find whether the given number or string is palindrome.
how to write optimum code to divide a 50 digit number with a 25 digit number??
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
What 'lex' does?
List some basic data types in c?
Differentiate between a for loop and a while loop? What are it uses?
What is an array in c?
what is the diffrenet bettwen HTTP and internet protocol
Explain continue keyword in c
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
What is the difference between ++a and a++?
Explain the difference between strcpy() and memcpy() function?
What is the value of h?