0 0 votes Programming in C programming-in-c + – Sourabh Kumar 825 views answer comment Share Follow Print See 1 comment 1 1 comment reply Gaurav Sharma commented May 18, 2016 reply Follow flag I don't know how you are getting this, but the program is not getting compiled on GCC because msg() must return an int but it is returning nothing. 0 0 replyShare Please log in or register to add a comment.
Best answer 3 3 votes First time when you have declared variable a then compiler has assigned the Garbage Value, which you are printing. Second time, msg() supposed to return some integer value but you are not returning any actual value hence compiler again returning a Garbage Value, which is going to override last Garbage value. Hence you are getting the different value than first one. rude answered May 17, 2016 • selected Jun 11, 2016 by rude rude comment Share Follow See all 3 Comments 3 3 Comments reply Sourabh Kumar commented May 18, 2016 reply Follow flag It is true that the datatype of function and return statement of that function must return the same type value. Means if int msg() {Return 2.30 } Is it possible or we must return only int value 0 0 replyShare rude commented May 19, 2016 reply Follow flag int msg(){ . . . return 2.50; } int main(){ int p; . . . p = msg(); . . } In this compiler give the warning but not error. And Implicit conversion will take place on 2.50 and 2 will be stored in the p. 2 2 replyShare rude commented May 19, 2016 reply Follow flag @sourabh kumar : If you satisfy then mark it best answer. Thx. 0 0 replyShare Please log in or register to add a comment.