pages

Sunday, 9 May 2021

c-program to print all prime number between 1 to 300 numbers | c-programming

 Program to print all prime number between  1 to 300 in c-programming:-

In this program , we will now taking  input from the user and print  all prime number between 1 to 300 numbers using for loop.

prime-number:- A number which is only divisible by 1 and itself is called prime number .

#include<stdio.h>
void main()
{
         int i,n;
         for(n=1;n<=300;n++){
                  for(i=2;i<=n-1;i++){
                           if(n%i==0)
                                    break;
                  }
                  if(i==n)
                           printf("%d ",i);
         }
         return(0);
}

output:-



For more c-programming:-
















No comments:

Post a Comment