Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c interview questions and answers

1
How to access a function only in a given file, in a C program?
  1. Define function with in a function.
  2. Use static function.
  3. Use private function.
  4. Create a function and put its prototype in header file.
Show Answer
Share Facebook gmail Twitter
2
What is the scope and life time of a static local variable declared in a function in C language?
  1. scope is with in that function, life is also with in that function.
  2. scope is with in that function, life is through out that program execution.
  3. scope is through out that file, life is with in that function.
  4. scope is through out that file, life is through out that program execution.
Show Answer
Share Facebook gmail Twitter
3
How to count how many number of times a function is being called in a C program?
  1. Use a local variable in that function and increment it.
  2. Use static local variable in that function and increment it.
  3. Use static global variable in that file and increment it inside that function.
  4. Use a global variable and increment it in that function.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
Which is faster, macro or a function in C language?
  1. Macros will be expanded inline, so will be faster compared to functions.
  2. Functions are slower because, switching between functions takes some time.
  3. option 1 and 2 are reversed.
  4. option 1 and 2 are correct.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Sample program for accessing global variable in a function using C program:

What is the output of below c program?

#include  <stdio.h>
static int fun(void);
int i=200;
int main(void)
{
    fun();
    return 0;
}
static int fun(){
    i++;
    printf("static function called..%d",i);
}
  1. compile time error, static functions can't access non static global variables.
  2. output can be 201, if no other out side file has modified i value.
  3. output is 201 in all the scenarios.
  4. compile time error, main can't access static function.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
What kind of function declarations should be put in .c files?
  1. Functions which are not visible to outside world, like static functions.
  2. we are not supposed to put any function declaration in .c file.
  3. we can put both static and global function declarations in .c file.
  4. we can put any kind of function declaration in .c file, no harm in doing so.
Show Answer
Share Facebook gmail Twitter
14
Is it possible to have same prototype [or] function declaration twice in a .c or .h file?
  1. No, we should have only one function declaration, else it gives compile time error.
  2. We can have duplicated function declarations in a file, compiler wont give error as long as both the signatures are same including return type.
  3. We can have duplicated function declarations in a file, compiler wont give error.
  4. We can have duplicated function declarations in a file, compiler wont give error as long as both  return types are same.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
16
What is the output of below c program?
assume that function fun() definition is not available.

#include  <stdio.h>
void fun(void);
int main(void)
{
    fun();
    return 0;
}
  1. function..
  2. no output no error
  3. compile time error, function definition not found.
  4. Linker error, function definition not found.
Show Answer
Share Facebook gmail Twitter
17
Is it possible to access static function of one file from other files in a C program?
  1. No, we can't access. it is restricted only for that file.
  2. You can use pointer to that function, and can call from any other file.
  3. Yes, we can call directly that function from out side.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :