First character of name of any function must be either alphabets or underscore in c


First letter or character of a function's name must be either an alphabet or underscore. If function name start from any digits or any other special character then we will get compilation error.

Example 1:

#include<stdio.h>
int main(){
   int min=1,max=100;
   int sum;
   sum= _digit_(min,max);
   printf("sum = %d",sum);
   return 0;
}
int _digit_(int min,int max){
   int total;
   total=(min+max)* (max-min+1)/2;
   return total;
}

Above code is valid in c programming.

Example 2:

#include<stdio.h>
float 1_centigrade(float);
int main(){
   float c,f;
   printf("Enter farehnite temp.");
   scanf("%f",&f);
   c=1_centigrade(f);
   printf("Centigrade temp. %f",c);
   return 0;
}
float 1_centigrade(float f){
   float c;
   c=(5*(f-32))/9;
   return c;
}

Output: Compilation error
Explanation: First character of a function name cannot have digit.

Post a Comment