write the program for prime numbers?
Answer Posted / kiran
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
int tn=1,c=0,flag=0;;
cin>>tn;
for(int i=3; c!=tn;i++)
{for(int j=2;j<i;j++)
{
if(i%j==0){
flag=0; break;}
else flag=1;
}
if(flag)
{c++;
printf("%d,",i);
}
}
getch();
return 0;
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the two types of structure?
What is the role of this pointer?
How can you call a function, given its name as a string?
What is malloc calloc and realloc in c?
How do you use a 'Local Block'?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
How can I read data from data files with particular formats?
What is time null in c?
What are the types of data types and explain?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What is the ANSI C Standard?
Why does the call char scanf work?
What is the significance of an algorithm to C programming?
When is a void pointer used?
What does volatile do?