Function with no Arguments but Return Value In C

  1. /*C program to check whether a number entered by user is prime or not using function with no arguments but having return value */  
  2. #include <stdio.h>  
  3. #include <conio.h>  
  4. int input();  
  5. void main(){  
  6.     int num,i,flag = 0;  
  7.     num=input();     /* No argument is passed to input() */  
  8.     for(i=2; i<=num/2; ++i){  
  9.     if(num%i==0){  
  10.         flag = 1;  
  11.         break;  
  12.     }  
  13.     }  
  14.     if(flag == 1)  
  15.         printf("%d is not prime",num);  
  16.     else  
  17.         printf("%d is prime", num);  
  18.     getch();  
  19. }  
  20. int input(){   /* Integer value is returned from input() to calling function */  
  21.     int n;  
  22.     printf("Enter positive integer to check:\n");  
  23.     scanf("%d",&n);  
  24.     return n;  
  25. }