Search Placementyogi.com
 

Advanced C Functions Objective Questions

  :: Topics ::

1

What will be the output of the program in 16 bit platform (Turbo C under DOS) ?

int main()
{
  int add();
  int x=20;
  x=add();
  printf("%d",x);
}

int add()
{
  _AX = 2013;
}
A.

0

B.

Garbage Value

C.

2013

D.

error: ‘_AX’ undeclared (first use in this function)

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

In Turbo C (Windows): The return value of the function is taken from the Accumulator _AX=1990. 

 

NOTE: It does not work in gcc compiler (Linux). Gives ‘_AX’ undeclared error.

 

You might be thinking that add() function is not returning any value (No return statement is there) still we are getting some value in x, how?.  Actually all functions return some value either explicitly using return or implicitly by default if return type of function is not void. 

 

 

 
2

What is the output of below program?

#include<stdio.h>
int main()
{
   float  x=fun(2,3);
   printf("%f",x);
}
int fun (int x,float y) //Line 7
{
     x = 20.9;   //Line 9
     return x;
}
A.

20.99000

B.

20.00000

C.

error at Line 9

D.

error: conflicting types for ‘fun’

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

Points to Remember

1. During compilation if prototype of function is not known to compiler then by default it assumes return type and all parameter type to int. 
2. By default it accepts any number of parameter but it should be less than max number of parameter allowed for functions in C.

In main function, definition of func() is not know to compiler during compilation so compiler assumed the return type and parameter type to int but in definition  when it sees the parameter type is float, so it throws conflicting types error.

 
 
 

Banner to LogicGuns.com

Hide Page Information

C Advanced Functions Multiple Choice Questions and Answers for Written Round Interview

Here you can find C Advanced Functions Multiple Choice Questions with answers and explanation. We have a vast collection of Multiple Choice Questions on Advanced Functions in C that will help you a lot!

Why learn C Advanced Functions?

Advanced Functions are an integral part of C and many Multiple Choice Questions in the written round are asked from this topic.In this section you can learn and practice C Advanced Functions (Multiple Choice Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get C Advanced Functions Multiple Choice Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved C Advanced Functions Multiple Choice Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for C Advanced Functions, We have quiz Multiple Choice Questions with answers to help you test yourself..

\n

Where can I get C Advanced Functions Interview Multiple Choice Questions and Answers (objective type, multiple choice)?

Here you can find objective type C Advanced Functions Multiple Choice Questions and answers for interview and entrance examination.Multiple Answers and true or false type Multiple Choice Questions are also provided.

How to solve C Advanced Functions problems?

You can easily solve all kind of Multiple Choice Questions based on C Advanced Functions by practicing the exercises (including shortcut Advanced Functions to solve problems) given below.