Name of function cannot be any keyword of c program


In c programming language a function name cannot be any keyword of c language. Function name can be keyword of c++ but it is bad practice. If function name is keyword of c language we will cause of compilation error.

Example:

#include<stdio.h>
int main(){
   int num,count;
   printf("\nEnter a number:");
   scanf("%d",&num);
   count=interrupt(num);

   if(count==2)
      printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);

   return 0;
}

int interrupt(int num){
   int i,count=0;
   for(i=1;i<=num;i++){
      if(num%i==0)
         count++;
   }

   return count;
}

Output: Compilation error
Explanation: interrupt is keyword of c language. It cannot be function name.

No comments: