Sail E0 Webinar

MCQs

Total Questions : 63 | Page 5 of 7 pages
Question 41.


How many times the program will print "Placementadda" ?


#include<stdio.h>
int main()
{
printf("Placementadda");
main();
return 0;
}
  1.    Infinite times
  2.    32767 times
  3.    65535 times
  4.    Till stack overflows
 Discuss Question
Answer: Option D. -> Till stack overflows

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.


Question 42.


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 */
}
  1.    1. KR Notation 2. ANSI Notation
  2.    1. Pre ANSI C Notation 2. KR Notation
  3.    1. ANSI Notation 2. KR Notation
  4.    1. ANSI Notation 2. Pre ANSI Notation
 Discuss Question
Answer: Option C. -> 1. ANSI Notation 2. KR Notation

KR Notation means Kernighan and Ritche Notation.


Question 43.

What will be output if you compile following c code ?


#include<stdio.h>
int add(a,b)
{
int c=a+b;
return c;
}
void main()
{
int a=10,b=20;
printf("%d",add(a,b));
}


  1.    Compile Error
  2.    30
  3.    0
  4.    None of these
 Discuss Question
Answer: Option B. -> 30



Question 44.

What will be output if you compile following c code ?


#include<stdio.h>
static int funct(int val;)
{
static int sum;
sum+=val;
return sum;
}
void main()
{
int i,n=9;
for(i=1;i
  1.    20
  2.    0
  3.    30
  4.    None of these
 Discuss Question
Answer: Option A. -> 20


Question 45.

The keyword used to transfer control from a function back to the calling function is


  1.    switch
  2.    goto
  3.    go back
  4.    return
 Discuss Question
Answer: Option D. -> return


The keyword return is used to transfer control from a function back to the calling function.
Example:


#include<stdio.h>
int add(int, int); /* Function prototype */
int main()
{
int a = 4, b = 3, c;
c = add(a, b);
printf("c = %d\n", c);
return 0;
}
int add(int a, int b)
{
/* returns the value and control back to main() function */
return (a+b);
}


Output:
c = 7


Question 46.

What will be output if you compile following c code ?


#include<stdio.h>
void main()
{
int add(int,int);
int a=7,b=13;
printf("%d",add(add(a,b),add(a,b)));
}
int add(a,b)
int a,b;
{
return (a+b);
}


  1.    Compile Error
  2.    20
  3.    40
  4.    None of these
 Discuss Question
Answer: Option C. -> 40



Question 47.

What will be output if you compile following c code ?


#include<stdio.h>
char funct(int val)
{
char ch=val;
return ch;
}
void main()
{
float a=256.25;
printf("%d",funct(a));
}


  1.    0
  2.    256
  3.    256.25
  4.    None of these
 Discuss Question
Answer: Option A. -> 0



Question 48.

What will be output if you compile following c code ?


#include<stdio.h>
int funct2(int b)
{
if(b==0)
return b;
else
funct1(b--);
}
int funct1(int a)
{
if(a==0)
return a;
else
funct2(a--);
}
void main()
{
int a=7;
printf("%d",funct1(a));
}


  1.    Compile Error
  2.    0
  3.    7
  4.    Infinite loop
 Discuss Question
Answer: Option D. -> Infinite loop



Question 49.

What will be output if you compile following c code ?


#include<stdio.h>
int val;
static int funct()
{
return val*val;
}
void main()
{
val=5;
funct();
val++;
printf("%d",funct());
}


  1.    compile error
  2.    25
  3.    36
  4.    None of these
 Discuss Question
Answer: Option C. -> 36


Question 50.

Point out the error in the program



f(int a, int b)
{
int a;
a = 20;
return a;
}


  1.    Missing parenthesis in return statement
  2.    The function should be defined as int f(int a, int b)
  3.    Redeclaration of a
  4.    None of above
 Discuss Question
Answer: Option C. -> Redeclaration of a


f(int a, int b) The variable a is declared in the function argument statement.



int a; Here again we are declaring the variable a. Hence it shows the error "Redeclaration of a"



Latest Videos

Latest Test Papers