closed by
631 views
0 votes
0 votes
closed with the note: Resolved

The Following code has output `Gate2019`

#include <stdio.h>

char* fun(){
    char* temp = "Gate2019";
    return temp;
}

int main(void) {
	// your code goes here
	puts(fun());
	return 0;
}
closed by

1 Answer

1 votes
1 votes
Here when function is called then temp pointer array of char is been created and is stored the value 'Gate2019'

and return statement contains the starting address of temp

so for string from obtained address till end until it finds null value is printed

Therefore from temp starting address till end value will be printed  so Gate2019 will be printed

Related questions

0 votes
0 votes
0 answers
1
0 votes
0 votes
0 answers
2
Nishi Agarwal asked Mar 10, 2019
512 views
A(n){if(n<1) return (1);else return A(n-2)+B(n-1);}B(n){if(n<=1) return 1;else return B(n-1)+A(n-2);}
0 votes
0 votes
1 answer
4