a function that receives two numbers as an argument and display all prime numbers between these two numbers. Call this function from main( ). Test Case 1 Input (stdin) 1 10 Expected Output 2 3 5 7 Test Case 2 Input (stdin) 88 101 Expected Output 89 97 101
#include<iostream> using namespace std; void showprime(int, int); int main() { int x,y; cin>>x; cin>>y; showprime(x,y); return 0; } void showprime(int a, int b) { bool flag; for(int i=a+1;i<=b;i++) { flag=false; for(int j=2;j<i;j++) { if(i%j==0) { flag=true; break; } } if(flag==false && i>1) cout<<i<<endl; } }