Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include<iostream>

using namespace std;

int main()

int num;

int primeTrue =0;

int primeFalse =0;

cout << "Enter an integer: ";

cin >> num; // Taking input

int i, chk=0, j;

cout<<"Prime Numbers Between 1 to 100 are:\n";

for(i=1; i<=num; i++)

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

if(i%j==0)

chk++;

break;

if(chk==0 && i!=1){

cout<<i<<endl;

++primeTrue;

}else{

++primeFalse;

chk = 0;

}
cout<<"primeTrue = "<<primeTrue << "\n";

cout<<"primeFalse = "<<primeFalse<< "\n";

cout<< "Prime true % = " << (primeTrue*100/num )<< "\n";

cout<< "Prime false % = " << (primeFalse*100/num ) << "\n";

return 0;

You might also like