A Little about the blog.....

This blog contains all the interview questions that i face during my interviews with various MNC's. I am trying to post the solutions for almost all the questions and i have covered few important topics which would be frequent topics in interviews. I hope the blog would be useful not only for the job aspirants but also to the one who tries to upgrade his/her knowledge in C and Embedded concepts......

please enter your mail address in the above mail address box to get the immediate updates of the new interview questions.....

Wednesday, November 16, 2011

difference between constant and static

we use the key words "CONSTANT" and "STATIC" while declaring the variables.

lets get in detail:

when we want the scope of the variable to be valid through out the program we declare the variable as static. to be more clear, the changes made to a static variable stands valid even when we move from one function to other function in the same program.

for example if we declare static int x=10 in main function and we incremented x and jumped to some other function and if we print x there, the value will be printed as 11.

coming to the CONSTANT, when we want the value of the variable to be constant all the time and should not be changed through out the program, we declare it as a constant.

hope u have got a clear idea by now. don't get confused with these two keywords as they look alike in sense.

No comments:

Post a Comment