65 834
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #22722 in C++ for EMMANUEL

Question #22722
write a program using c++ to find the sum of 1st 10 prime numbers.
Expert's answer
#include<iostream>
using namespace std;

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;
}

int count = 0, sum = 0, i = 1;

void main(){
while (count<11){
if (isprime(i)){
cout<<i<<"\n";
count++;
sum+=i;
}
i++;
}
cout<<"The sum of 1st 10 prime numbers is "<<sum<<"\n";
system("pause");
}

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