write the program for prime numbers?
Answer Posted / karthikeyan murugesan
hi u can try this one for prime number and generation ::
#include<stdio.h>
void main()
{
int n,i=1,j,c;
scanf("%d",&n);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
{
printf("%d",i);
i++;
}
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the difference between formatted&unformatted i/o functions?
What's the best way of making my program efficient?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
Why do we use & in c?
What is the difference between NULL and NUL?
What does node * mean?
How does pointer work in c?
What is static and auto variables in c?
Can I initialize unions?
Differentiate between #include<...> and #include '...'
What is the function of this pointer?
Where does the name "C" come from, anyway?
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
Why is structure important for a child?
Can we declare variable anywhere in c?