64 584
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #5459 in C++ for zuhaib abbasi

Question #5459
write a program in c++ that display the first 20 prime number using while loop.
Expert's answer

# include<iostream.h>
# include<conio.h>

//calculation
int isprime(int valuex)
{
int x,j;
x=1;
& for (j=2 ; j<valuex; j++)
{ if ((valuex%j)==0) x=0; }
& if(x!=0) return 1;
& else return 0;
}

void main(){
int i, n;
i=0;
n=0;
while (n<20){
& if (isprime(i)==1) { cout<<i<<"\n"; n++; }
& i++;
}
getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions