TheFestFever.com

Our aim is to connect students from campuses all over Delhi by making them aware of all Technical, Cultural, Management fests, workshops, Seminars organized by every college in Delhi.

Join Us Now

Program 19: Write a C++ program to print all the prime numbers lying between 1 and 100.

#include<iostream>
using namespace std;

int main()
{
	int i,j,x=0,p=0,check=0;
	cout<<"\nprime numbers btw 1 to 100 are:";
	cout<<"\n2";

	for(i=3;i<=100;i++)
	{
		for(j=2;j<i;j++)
		{
			if(i%j==0)
			{
				check=1;
				break;
			}
		}

		if(check==1)
			x++;
		else
			cout<<"\t"<<i;

		check=0;
	}
	cout<<"\ntotal prime numbers btw 1 to 100 is:";
	p=100-(x+1);
	cout<<p;
	return 0;
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.