Prime numbers from 1 to 100 using function - C

Write a C program to display all prime numbers between 1 to 100 by using function.

Solution:

#include<stdio.h>
void prime()
{
     int i=2,j,p;
     while(i<=100)
     {
          p=1; // Initially p=1
          for(j=2;j<i;j++)
          {
               /*Here, we check if it is divisible by any other number
               other than 1 or itself*/
               if( i%j == 0)
               {
                    p=0;
               }
          }
          if(p)
          {
               printf("\t%d\n",i);
          }
     i++;
     }
}
int main()
{
     printf("Prime Numbers Between 1 to 100\n");
     printf("--------------------------------\n");
     prime();
     return 0;
}


Output:

prime numbers 1 to 100