Function with no Arguments and no Return Value In C

  1. #include <stdio.h>  
  2. #include <conio.h>  
  3. void prime();  
  4. void main(){  
  5.     prime();      //No argument is passed to prime().  
  6.     getch();  
  7. }  
  8. void prime(){    
  9. /* There is no return value to calling function main(). Hence, return type of prime() is void */  
  10.   
  11.     int num,i,flag=0;  
  12.     printf("Enter positive integer enter to check:\n");  
  13.     scanf("%d",&num);  
  14.     for(i=2;i<=num/2;++i){  
  15.         if(num%i==0){  
  16.              flag=1;  
  17.          }  
  18.     }  
  19.     if (flag==1)  
  20.         printf("%d is not prime",num);  
  21.     else  
  22.        printf("%d is prime",num);    
  23.     }