functions (3.papers)

loops (1.papers)

Conditional statements (2.papers)

arrays (2.papers)

structures (3.papers)

unions (1.papers)

Enums and TypeDefs (3.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)

bitwise operators (1.papers)

1

Finding Odd or even number by using a C program: fun(int num){ if(num % 2 == 0){ printf(""); }else{ print(""); } }

it will find if number passed to this function is 0 or 2

it will find if number passed to this function is 1 or 2

it will find if number passed to this function is odd or even

it will find if number passed to this function is prime or not

Show Answer

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; }

This is an iterative way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)

this is an iterative way to generate fibonacci series of n-numbers.

This is an recursive way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)

this is recursive way to generate fibonacci series of n-numbers.

Show Answer

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 }

line 5: it is function declaration line 7: it is function call

line 5: it is function call line 7: it is function definition

line 5: it is function call line 7: it is function declaration & definition both.

line 5: it is function declaration line 7: it is function definition

Show Answer

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 }

line 6:i is actual parameter line 8: j is actual parameter

line 6:i is formal parameter line 8: j is actual parameter

line 6:i is actual parameter line 8: j is formal parameter

line 6:i is formal parameter line 8: j is formal parameter

Show Answer

5

Sample code for passing an integer parameter to a function in C program: What will be the output of below C program? #include <stdio.h> main() { int i=10; fun(i); printf("%d",i); } void fun(int i) { i = i+10; printf("%d\n",i); }

20,10

20,20

compile time error

10,20

Show Answer

6

Sample code for passing and returning an integer value from a method in C program: What will be the output of this below program? #include <stdio.h> main() { int i = 10; i = fun(i); i++; printf("%d",i); } int fun(int i) { i = i+10; printf("%d\n",i); return i; }

20,11

20,21

compile time error

10,21

Show Answer

Show Answer

8

Can a function return multiple values in C program?

yes

no

yes, but by returning structures or arrays or unions or other data structures

can't say

Show Answer

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?

No, pass by value will not have any effect.

Yes, pass by value will have effect if called functions changes the value passed to it.

can't say

none

Show Answer

10

What is the use of functions in C? When to use functions in C?

if same piece of code has to be executed again and again, then we can put that code in a function.

if we want to create any library, then we can create functions and convert them into libraries.

it is a tool to modularize the project it smaller chunks, so that maintenance of code will be easy.

all of the above

Show Answer

11

Sample code for declaring formal parameters out side the method in C program: What will be the output of this below program? #include <stdio.h> main() { fun(10); } void fun(i) int i; { printf("%d",i); }

compile time error

it will crash at run time

10

no output no error

Show Answer

Show Answer

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); }

It is finding factorial of passed number using recursion technique.

it is finding Fibonacci series till number 'n' using recursion technique.

it is finding Fibonacci series till number 'n' using iteration technique.

It is finding factorial of passed number using iterative technique.

Show Answer

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"); }

it is recursive function, it will execute properly but no output.

it is recursive function, it will execute properly with "i am in home" output.

compile time error.

it is recursive function call, it will crash at run time due to stack over flow with out any output.

Show Answer

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) ; }

it is calculating power(y, 2)

calculates power(y, x). i.e y*y*y.. for x times.

it is calculating power(x, 2)

calculates power(x,y). i.e x*x*x.. for y times.

Show Answer

16

C program for calculating power using a method: What is below program doing? #include <stdio.h> int main(int argc, char*argv[]) { printf("\n[%d]\n",find(5,4)); } int find(int x, int n) { if(n==0)return(1); else if(n%2==0) { return(find(x,n/2)*find(x,(n/2))); } else { return(x*find(x,n/2)*find(x,(n/2))); } }

calculates if x is divisible by n or not, using divide and conquer technique.

calculates power(n,x) using divide and conquer technique.

calculates power(x,n) using divide and conquer technique.

none

Show Answer

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) }

this is a iterative way to generate Fibonacci series.

this is recursive way to find factorial of a given number

This is a recursive way to do Fibonacci series.

this is an iterative way to find factorial of a given number.

Show Answer

18

Is the following C code correct? void f(int, int=10); void f(int a,int b ){...} void main(){ .... ... f(5); ... }

illegal

TRUE

FALSE

depends on compiler

Show Answer

19

Sample code for returning a value from a method in C language: What will be the output of this below program? #include <stdio.h> main() { int i; i = fun(10); printf("%d",i); } int fun() { return 100; }

100

10

compile time error

run time error.

Show Answer

20

How to use a method signature in C: What will be the output of below C program? #include <stdio.h> int fun(void); main() { int i; i = fun(10); printf("%d",i); } int fun() { return 100; }

100

10

compile time error

run time error.

Show Answer