Code for prime number in c++






Code for prime number in c++

#include<iostream>
#include<iomanip>

int main(){
    int num,i,count;
 
    for(num = 1;num<=100;num++){
         count = 0;

         for(i=2;i<=num/2;i++){
             if(num%i==0){
                 count++;
                 break;
             }
        }
       
         if(count==0 && num!= 1)
             cout <<  num  << setw(3);
    }
 
   return 0;


No comments: