Write a C program to display a prime number in between 1 and 100.

#include<stdio.h>

#include<math.h>

 

int main()

   {

     int   i, j, isprime;

     for(i=2;i<=100;i++)

         {

           isprime=1;

           for(j=2;j<=sqrt(i);j++)

                 if(i%j==0)

                 {

                     isprime=0;

                     break ;

                 }

            if(isprime==1)

                 printf( "%8d" ,i);

           }

       return  0;

    }

No comments:

Post a Comment

Post a Comment