a c++ program that calculates and displays the sum of all prime numbers in a user-defined closed interval [a,b] of positive integers using both pre-defined and user-defined functions.
1
Expert's answer
2012-10-19T08:57:46-0400
#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 a,b;
void main(){ cout<<"primes from "<<a<<" to "<<b<<":\n"; a=10; b = 101; for (int i=a; i<=b; i++) & if (isprime(i)) cout<<i<<" "; cout<<"\n"; cout<<"enter a:"; cin>>a; cout<<"enter b:"; cin>>b; cout<<"primes from "<<a<<" to "<<b<<":\n"; for (i=a; i<=b; i++) & if (isprime(i)) cout<<i<<" "; cout<<"\n"; system("pause"); }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment