PROGRAMMING:Pointer function (code analysis)
```
Analyzing code to understand pointer function
#include
char *day_ name(int n); // Function declaration
int main(){
int i;
for(i=0; i<=8; i++)
printf("The %dth day of the week :%s\n",i,day_ name(i));
return 0;
}
char *day_ name(int n){
static char *name[]={ "NOT DEFINE","Sunday","Monday","Tuesday",
"Wednesday","Thursday","Friday","Saturday"};
return((n<1||n>7) ? name[0] : name[n]);
}
Execute program output:
The 0th day of the week :NOT DEFINE
The 1th day of the week :Sunday
The 2th day of the week :Monday
The 3th day of the week :Tuesday
The 4th day of the week :Wednesday
The 5th day of the week :Thursday
The 6th day of the week :Friday
The 7th day of the week :Saturday
The 8th day of the week :NOT DEFINE
```
###Input example:
```in
```
###Output example:
```out
The 0th day of the week :NOT DEFINE
The 1th day of the week :Sunday
The 2th day of the week :Monday
The 3th day of the week :Tuesday
The 4th day of the week :Wednesday
The 5th day of the week :Thursday
The 6th day of the week :Friday
The 7th day of the week :Saturday
The 8th day of the week :NOT DEFINE
```
answer:If there is no answer, please comment
Analyzing code to understand pointer function
#include
char *day_ name(int n); // Function declaration
int main(){
int i;
for(i=0; i<=8; i++)
printf("The %dth day of the week :%s\n",i,day_ name(i));
return 0;
}
char *day_ name(int n){
static char *name[]={ "NOT DEFINE","Sunday","Monday","Tuesday",
"Wednesday","Thursday","Friday","Saturday"};
return((n<1||n>7) ? name[0] : name[n]);
}
Execute program output:
The 0th day of the week :NOT DEFINE
The 1th day of the week :Sunday
The 2th day of the week :Monday
The 3th day of the week :Tuesday
The 4th day of the week :Wednesday
The 5th day of the week :Thursday
The 6th day of the week :Friday
The 7th day of the week :Saturday
The 8th day of the week :NOT DEFINE
```
###Input example:
```in
```
###Output example:
```out
The 0th day of the week :NOT DEFINE
The 1th day of the week :Sunday
The 2th day of the week :Monday
The 3th day of the week :Tuesday
The 4th day of the week :Wednesday
The 5th day of the week :Thursday
The 6th day of the week :Friday
The 7th day of the week :Saturday
The 8th day of the week :NOT DEFINE
```
answer:If there is no answer, please comment