C program to find all the prime numbers in 1 to 100.

Interview Programming

 

Prime Number:

A positive number whose divisors only 1 and the number itself (among all the positive numbers) are known as prime number.

Example: 1,2,3,5,7,11.

Among positive even  number only 2 is the prime number rest of all the prime numbers are odd(positive) number.

#include<stdio.h>
int main()
{
int number,i,j,primeNumber,low=1,high=100;
printf(" Prime Numbers are: \n");
for(j=low;j<=high;j++){
primeNumber=0;
for(i=2;i<=j/2;i++){
if(j%i==0){
primeNumber++;
break;
}
}
if(primeNumber==0 && j !=1)
printf("%d\t ",j);
}
return 0;
}

output:

Prime Numbers are:
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

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...