Function which is returning char data type in c programming.

char find_character();
void main(){
char character;
character=find_character();
printf("Character : %c",character);
getch();
}
char find_character(){
char * string="cquestionbank",temp;
string+=3;
temp=*string;
return temp;
}
Output: e

2 comments:

Anonymous said...

why is the output e?

Unknown said...

In the function find_character() initially string points the starting character 'c' from "cquestionbank"
if we increase string + 1 it points the character q
similarly string + 2 it points the character u
string + 3 it points the character e
finnally it stored in tem.so output is e only