C Programming Interview Questions


C Programming Interview Questions.

C Language Basics:


The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIXoperating system. It is one of the most widely used programming  languages. It is the most popular programming language for writing system software, though it is also used for writing applications.



Local block :
  •   A local block is any portion of a C program that is enclosed by the left brace ({) and the right brace (}).
  •  A C function contains left and right braces, and therefore anything between the two braces is contained in a local block.
  • An if statement or a switch statement can also contain braces, so the portion of code between these two braces would be considered a local block.


Output of printf("%d") : printf() Function :

printf("%d",x) - Compiler will print the value of x.

  •             When we use %d the compiler internally uses it to access the argument in the stack (argument stack).
  •          Ideally compiler determines the offset of the data variable depending on the format specification string.
  •          Now when we write printf("%d",a) then compiler first accesses the top most element in the argument stack of the printf which is %d and depending on the format string it calculated to offset to the actual data variable in the memory which is to be printed.
  •          Now when only %d will be present in the printf then compiler will calculate the correct offset (which will be the offset to access the integer variable) but as the actual data object is to be printed is not present at that memory location so it will print what ever will be the contents of that memory location.
  •          Some compilers check the format string and will generate an error without the proper number and type of arguments for things like printf(...) and scanf(...).




 ï Home                                                                                                                             Next  ð
                                                                                                                               
Share this article :
 

Post a Comment

Note: Only a member of this blog may post a comment.