RejinpaulPlacement
Search

Functions - C Programming Questions and Answers - RejinpaulPlacement

@ : Home > C Programming > Functions


Find us on Facebook



Follow us on Google+


Google+

1.
How many times the program will print "IndiaBIX" ?
#include
int main()
{
printf("IndiaBIX");
main();
return 0;
}
Answer & Solution
Answer: (D) Till stack overflows
Solution: A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing.

A stack overflow occurs when too much memory is used on the call stack.

Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.

close
2.
What is the notation for following functions?

1. int f(int a, float b)
{
/* Some code */
}

2. int f(a, b)
int a; float b;
{
/* Some code */
}
Answer & Solution
Answer: (C) 1. ANSI Notation 2. KR Notation
Solution: KR Notation means Kernighan and Ritche Notation.
close
3.
The keyword used to transfer control from a function back to the calling function is
Answer & Solution
Answer: (D) return
Solution: The keyword return is used to transfer control from a function back to the calling function.
close
4.
What will be the output of the program?

#include
#include
int main()
{
int i=0;
i++;
if(i<=5)
{
printf("IndiaBIX");
exit(1);
main();
}
return 0;
}
Answer & Solution
Answer: (D) Prints "IndiaBIx"
Solution: Step 1: int i=0; The variable i is declared as in integer type and initialized to '0'(zero).

Step 2: i++; Here variable i is increemented by 1. Hence i becomes '1'(one).

Step 3: if(i<=5) becomes if(1 <=5). Hence the if condition is satisfied and it enter into if block statements.

Step 4: printf("IndiaBIX"); It prints "IndiaBIX".

Step 5: exit(1); This exit statement terminates the program execution.

Hence the output is "IndiaBIx".
close
5.
What will be the output of the program?

#include
int fun(int);
int main()
{
float k=3;
fun(k=fun(fun(k)));
printf("%f\n", k);
return 0;
}
int fun(int i)
{
i++;
return i;
}
Answer & Solution
Answer: (A) 5.000000
Solution: No answer description available for this question.
close