×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
auto and static variables, Sort the character, factorial of a Number
Prime no from 1 - 100 - MCA WBUT MAKAUT - C Language
570    Arnab De    12/05/2020

Write a C program to print the prime numbers between 1 to 100.

If a number has only two factors, 1 & itself, then that number known as Prime Number. In others words, we can say that, a prime no cannot be divided by any numbers between 2 and [that number -1]. As a number cannot be divided by the any number which greater than its half. That is if a number not divide by the number between 2 and half of its numbers, then that number known as prime numbers.

softetechnologies

As we know matematically 1 is not a prime number. we create a loop from 2 to 100. Now check each number for prime number. if it is a prime no then print it.

void main()
{
	int N=100,i,d,j,fl;
	clrscr();
	for(i=2;i<=N;i++)
	{
		fl=1;
		for(d=2;d<=i/2;d++)
		{
		     if(i%d==0)
		     {
			fl=0;
			break;
		     }
		}
		if(fl)
		{
			printf("%d  ",i);
		}
	}
}
softetechnologies

Output

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

auto and static variables, Sort the character, factorial of a Number
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
As long as I live, so long do I learn
Sri Sri Ramakrishna Paramahamsa
1736
35.58
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     33880
28/06/2017     30126
26/05/2018     28037
02/08/2017     27820
15/05/2017     23768
25/06/2018     22413
06/07/2017     22315
01/08/2017     22297
21/04/2018     18818
14/07/2017     17257
softetechnologies