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.
Definition of function in c
Name of function includes only alphabets, digit and underscore.
First character of name of any function must be an alphabet or underscore.
Name of function cannot be any keyword of c program.
Name of function cannot be global identifier.
Name of function cannot be exactly same as of name of function in the same scope.
Name of function is case sensitive
Name of function cannot be register Pseudo variable
Name of function includes only alphabets, digit and underscore.
First character of name of any function must be an alphabet or underscore.
Name of function cannot be any keyword of c program.
Name of function cannot be global identifier.
Name of function cannot be exactly same as of name of function in the same scope.
Name of function is case sensitive
Name of function cannot be register Pseudo variable
No comments:
Post a Comment