Friday, September 13, 2019

C++ code - Prime number with in given range

Code


   #include <iostream>
using namespace std;
int main()
{

          int i=2, j, is_prime, max, min;

 // we are going to add 2 more variable for maximum and minimum number

   

 cout <<"Enter a minimum number : ";cin>>min; cout<<endl;




cout<<"Enter a maximum number : ";cin>>max;


//because 1 or 0 is not prime number so we set the minimum bigger than 1
   

       i=min;
     while(i<max)
   {


  is_prime=true;

  for(j=2; j<i; j++)
  {
  if(i%j==0)
  {
  is_prime= false;
  }


  }
  if(is_prime)
{
if(i>1)
cout<<i<<" ";
}
  i++;
}




 return 0;

}


output -



Video link of this code - click me



1 comment:

  1. During casinos' off-seasons, it's normal for them to attempt to lure you in with free play, free food, or a free hotel stay . So if you're going to spend your cash anyway, you would possibly as properly join. 더온카지노 Always verify the player desk daily to study daily promotions and special presents; lots of them usually are not advertised on-line. Diamond later exchanged the Coins Platinum had won for a Zoom Lens. As players use the slot machine, a Smeargle depicted on the top screen and seen portray can change the background of the top screen's monitor, and any change in background modifications slot effects. A green background indicators normal play, a red background indicators that it's easier to obtain a 7 or Poké Ball, and a blue background indicators that it's easier to obtain a Pikachu or Marill.

    ReplyDelete

C++ BLACKJACK

#include <iostream> #include <ctime> #include <stdlib.h> #include <time.h> #include <string> using namesp...