Friday, September 13, 2019

Write a C++ code that will only print prime numbers 0 to 100

Code

#include <iostream>
using namespace std;

int main(){
 int i=2, j, is_prime;
 // we set i = 2 because prime numbers start at 2.
 while(i<100) {
              is_prime=true;

              for(j=2; j<i; j++){

                                       if(i%j == 0){
                                       is_prime = false;
                                                           }
                                        }
                           if(is_prime){
                           cout<< i <<" ";
                 }

                i++;
               }



 return 0;

}

Video link of this code with output click here


output -



1 comment:

  1. As in Pakistan, there is a nice variety of bettors who choose to bet online on well-known websites from 사설토토 the West. India is experiencing a rapid progress of its online playing market, although playing as an entire may be very restricted throughout the country. Horse racing and lotteries are the one fully authorized playing actions.

    ReplyDelete

C++ BLACKJACK

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