Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

static: 1)if defined in a function,its scope is inside the function and the value can be kept.
2)if defined outside any functions ,it is global in the file.
Create when the logic me the variable,destroy when main exit

- anonymous December 21, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The extern specifier is used when you've declared global variables elsewhere in a separate file for your program. Only global variables can be declared with the extern specifier. When the compiler sees the extern keyword, it'll look in another file for the definition of the variable. This can also be used for function, which we'll see later on.

The static specifier was mentioned in the File Scope section, and can be used on local or global variables to give them permanent duration for that file only. In other words, the memory space reserved for the variable is not erased once the variable is out of its scope.

The register specifier supposedly improves the efficiency of your program. When you declare a variable space in the computer's memory is set aside for it. The computer's central processing unit (CPU) has a few registers which can also take variables in. For the computer, accessing a variable stored in the registers is quicker as opposed to the computer's memory.

The downside is that it is not 100% guaranteed that a variable declared with the register specifier is going to be stored in a register. And you cannot use the "Address of" operator with the variable (like in scanf) because it's not stored in the memory and wouldn't have an address.

So when would you want to use the register specifier? Probably if you have a variable that changes its value often. Like, for example, in a for loop when the value changes after each iteration.

Taken from: http://irc.essex.ac.uk/www.iota-six.co.uk/c/d5_variable_scope.asp

- Anonymous January 10, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Excellent. Thanks.

- Anonymous November 30, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More