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
Finding Odd or even number by using a C program:

fun(int num){
        if(num % 2 == 0){
                printf("");
        }else{
                print("");
        }
}
  1. it will find if number passed to this function is 0 or 2
  2. it will find if number passed to this function is 1 or 2
  3. it will find if number passed to this function is odd or even
  4. it will find if number passed to this function is prime or not
Show Answer
Share Facebook gmail Twitter
2
Fibonacci series program in C language:

int fib(int n)
{
    int a = 1, b = 1;
    for (int i = 3; i <= n; i++) 
    {
        int c = a + b;
        a = b;
        b = c;
    } 
    return a;
}
  1. This is an iterative way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)
  2. this is an iterative way to generate fibonacci series of n-numbers.
  3. This is an recursive way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)
  4. this is recursive way to generate fibonacci series of n-numbers.
Show Answer
Share Facebook gmail Twitter
3
Difference between function call, function declaration, and function definition in C language:

In the below program,
line 5: Is it a function call or declaration or definition?
line 7: Is it a function call or declaration or definition?

1  #include  <stdio.h>
2  static int i=10;
3  main( )
4  {
5      fun();
6  }
7  void fun()
8  {
9    printf("welcome fun");
10 }
  1. line 5: it is function declaration
    line 7: it is function call
  2. line 5: it is function call
    line 7: it is function definition
  3. line 5: it is function call
    line 7: it is function declaration & definition both.
  4. line 5: it is function declaration
    line 7: it is function definition
Show Answer
Share Facebook gmail Twitter
4
Difference between actual parameters and formal parameters in C language:

line 6: what is i? actual parameter or formal parameter?
line 8: what is j? actual parameter or formal parameter?

1  #include  <stdio.h>
2  static int i=10;
3  main( )
4  {
5      int i=10;
6      fun(i);
7  }
8  void fun(int j)
9  {
10     printf("welcome fun");
11 }
  1. line 6:i is actual parameter
    line 8: j is actual parameter
  2. line 6:i is formal parameter
    line 8: j is actual parameter
  3. line 6:i is actual parameter
    line 8: j is formal parameter
  4. line 6:i is formal parameter
    line 8: j is formal parameter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Can a function return multiple values in C program?
  1. yes
  2. no
  3. yes, but by returning structures or arrays or unions or other data structures
  4. can't say
Show Answer
Share Facebook gmail Twitter
9
If a function is called by passing a value, and if the called function has changed the value passed, then will it have any effect on calling function's value?
  1. No, pass by value will not have any effect.
  2. Yes, pass by value will have effect if called functions changes the value passed to it.
  3. can't say
  4. none
Show Answer
Share Facebook gmail Twitter
10
What is the use of functions in  C? When to use functions in C?
  1. if same piece of code has to be executed again and again, then we can put that code in a function.
  2. if we want to create any library, then we can create functions and convert them into libraries.
  3. it is a tool to modularize the project it smaller chunks, so that maintenance of code will be easy.
  4. all of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
Factorial program in C language:

What is below function doing?

fun(int n)
{
  int f;
  if(n==1)
    return(1);
  else
    f = n * fun(n-1);
  return(f);
}
  1. It is finding factorial of passed number using recursion technique.
  2. it is finding Fibonacci series till number 'n' using recursion technique.
  3. it is finding Fibonacci series till number 'n' using iteration technique.
  4. It is finding factorial of passed number using iterative technique.
Show Answer
Share Facebook gmail Twitter
14
Sample code for main() method calling main()

What will be the output of this below program?

#include  <stdio.h>

main( )
{
    main();
    printf("I am in home");
}
  1. it is recursive function, it will execute properly but no output.
  2. it is recursive function, it will execute properly with "i am in home" output.
  3. compile time error.
  4. it is recursive function call, it will crash at run time due to stack over flow with out any output.
Show Answer
Share Facebook gmail Twitter
15
C program for calculating power of a number:

What does below function do?

int calc(int x, int y)
{
if(y == 1) return x ;
return x * calc(x, y-1) ;
}
  1. it is calculating power(y, 2)
  2. calculates power(y, x). i.e y*y*y.. for x times.
  3. it is calculating power(x, 2)
  4. calculates power(x,y). i.e x*x*x.. for y times.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
17
Fibonacci series program code in C language:

What does below function do?.

int test(int n)
{
  if (n <= 2) return 1
  else return test(n-1) + test(n-2)
}
  1. this is a iterative way to generate Fibonacci series.
  2. this is recursive way to find factorial of a given number
  3. This is a recursive way to do Fibonacci series.
  4. this is an iterative way to find factorial of a given number.
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 :