Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Functions

Home > C Programming > Functions > General Questions

11. What will be output of the following "c" code?

#include
int main(){
int i=3,val;
val=sizeof (f(i)+ +f(i=1)+ +f(i-1));
printf("%d %d",val,i);
return 0;
}
int f(int num){
return num*5;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

12. What will be output of the following "c" code?

#include
int main(){
int a=1,x;
x=sq(++a)+sq(a++)+sq(a++);
printf("%d",x);
return 0;
}
int sq(int num){
return num*num;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

13. In the following code in which order the functions would be called ?

a = (fl (23, 14) * f2(12/4)) + f3();

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

14. What error would the following function given on compilation?

#include
int fun(int a, int b)
{
int a;
a=20;
return a;
}

void main()
{
int x = fun(1,3);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

15. How many times the following 'C' program would print 'Jamboree'?

#include
void main()
{
printf ("\nJamboree");
main();
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

16. What is the output of the following 'C' program?

#include
void main() {
int * j;
void fun(int **);
fun(&j);
}
void fun(int **k) {
int a =0;
*k = &a;
printf("%d",**k);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

17. What is the output of the following 'C' program?

#include
func(a,b)
int a,b;
{
return( a=(a==b) );
}
void main()
{
int process(),func();
printf("The value of process is %d \n ",process(func,3,6));
}
process(pf,val1,val2)
int (*pf) ();
int val1,val2;
{
return((*pf) (val1,val2));
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

The function 'process' has 3 parameters.
First argument a pointer to another function 2 and 3 argument are integers.
When this function is invoked from main, the following substitutions for formal parameters take place: func for pf, 3 for val1 and 6 for val2.
This function returns the result of the operation performed by the function 'func'.
The function func has two integer parameters.
The formal parameters are substituted as 3 for a and 6 for b.
since 3 is not equal to 6, a==b returns 0.
So the function returns 0 which in turn is returned by the function 'process'.

Workspace

Tags:

No Tags on this question yet!

18. What is the output of the following 'C' program?

#include
int aaa()
{
printf("Hi");
}
int bbb(){
printf("hello");
}
int ccc(){
printf("bye");
}

void main()
{
int ( * ptr[3]) ();
ptr[0] = aaa;
ptr[1] = bbb;
ptr[2] =ccc;
ptr[2]();
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

int (* ptr[3])() says that ptr is an array of pointers to functions that takes no arguments and returns the type int.
By the assignment ptr[0] = aaa;
it means that the first function pointer in the array is initialized with the address of the function aaa.
Similarly, the other two array elements also get initialized with the addresses of the functions bbb and ccc.
Since ptr[2] contains the address of the function ccc, the call to the function ptr[2]() is same as calling ccc().

Workspace

Tags:

No Tags on this question yet!

19. What will be output of the following "c" code?

#include
char *someFun()
{
char *temp = "string constant";
return temp;
}
int main()
{
puts(someFun());
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

The program suffers no problem and gives the output correctly because the character constants are stored in data segment and not allocated in stack, so this doesn't lead to dangling pointers.

Workspace

Tags:

No Tags on this question yet!

20. What will be output of the following "c" code?

#include
char *someFun1()
{
char temp[] = "string";
return temp;
}
char *someFun2()
{
char temp[] = {'s', 't','r','i','n','g'};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!