1 1 vote Whenever we declare a variable then compiler will not look for other details such as definition of the variable. why is this statement true ? Unknown Category programming-in-c + – Akhil01 816 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 2 2 votes Explanation : The compiler only needs to have a declaration for something in order to compile a file into an object file, expecting that the linker (you might have heard these terms as Linker and Loader) can find the definition from another file. If no source file ever defines a symbol, but it is declared, you will get errors at link time complaining about undefined symbols. Don't you worry answered Jul 17, 2016 • selected Jul 17, 2016 by Akhil01 Don't you worry comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes A variable in simple terms is a storage place which has some memory allocated to it when we declare a variable memory is not allocated for that that's why we can declare variable more than one time but it should be defined only once. At the time of definition, memory is allocated for it // This is only declaration. y is not allocated memory by this statement extern int y; // This is both declaration and definition, memory to x is allocated by this statement. int x; we can do both declare and define at same time we need seperate declaration and definition in case of extern and functions. u can refer: http://quiz.geeksforgeeks.org/commonly-asked-c-programming-interview-questions-set-1/ cse23 answered Jul 17, 2016 cse23 comment Share Follow See 1 comment 1 1 comment reply shekhar chauhan commented Jul 17, 2016 reply Follow flag @cse23 can we declare a variable in the same scope more then once ? 0 0 replyShare Please log in or register to add a comment.