img
Question:
Published on: 25 December, 2024

Write a C program to print all prime no.(1-100).

Answer:

 

#include<stdio.h>
#include<conio.h>
main()
{
	int i,j,n;
	printf("\n The prime numbers are(1-100)");
	for(i=2;i<=100;i++)
	{
		for(j=1;j<=i;j++)
		{
			if(i%j==0)
			n++;
		}
		if(n==2)
		printf(" %d",i);
		n=0;
	}
	getch();
}


Output:

Random questions