1. What is the output
of the following code? Justify your answer.
#include<stdio.h>
int
add(int x, int y)
{
return (x+y);
}
int
subtract(int x, int y)
{
return(x-y);
}
int
multiply(int x, int y)
{
return(x*y);
}
int
main()
{
int
(*fnarry[3])(int,int)={add,subtract,multiply};
int i=0;
printf("\n%d\n",(fnarry[i+1]+1)(5,6));
}
2.
Impliment recursively xpowery i.e power(x,y).
3.
Give anew method which performs same as below methods.
Method 1: if(x
== 0) Method 2: switch(x) {
fn0();
case 0: fn0();
else
if(x = 1) break;
fn1(); case 1: fn1();
else
if(x = 2) break;
fn2();
case 2: fn2();
else
fnX(); break;
default: fnX();
}
4. void fun(int p)
{
p=p+1;
return;
}
int main()
{
int p = 012
fun(p);
printf("%d\n",p);
}
5. extern int
add(int,int);
extern int i;
int main()
{
printf("%d",add(100,200));
}
int add(int a, int b)
{
int i;
i=a+b;
return(i);
}
6. What is size of
following..
int *a[10];
int (*fun)();
void *fun();
7. file1:
int a[10];
fun(int a[],int size)
{
printf("%d\n", sizeof(a));
file2:
extern int a[];
extern fun(int [],int);
int main
{
fun(a, sizeof(a));
}
8. #include <stdio.h>
main ()
{
add(95,54);
}
void add(int a, int b)
{
int c;
c = a+b;
printf("%d\n", c);
}
is there any problem
with code?if YES.what is it?how do u fix it?
9. #include <stdio.h>
int main()
{
int i = 012;
fun(i);
printf("%d\n", i);
}
fun(int i)
{
i += 1;
}
10. struct exp{
int a;
int b;
int c;
}
int fun(struct exp *s1)
{
printf("%d",s1->a);
printf("%d",s1->b);
printf("%d",(*s1).c);
}
11. int main()
{
struct exp s1;
s1.a=10;
s1.b=20;
s1.c=30;
fun(&s1);
}
1. What is Call by
value and Call by reference?Explain with an example.
2. What is
function?advantage of function over macro.
3. How variable
argument lists works in c? Explain with an example
4. What happens if a
variable is static within the recursion ?
5. recursive function
to find the factorail of a number.
6. What is call back
fuction & reentrant code?
7. How to pass entire
array to a function as call by value ?
8. How stack frames are
created when function is invoked?
9. Explain
int * (*fun)(int
(*a)[])
10. What is inline
function, how the compiler will recognizes whether it is inline or not, what is
the
difference between
inline and a normal function
11. What are the
advantages of the functions?
12. What is the purpose
of main( ) function?
13. What is an argument
? differentiate between formal arguments and actual arguments?
14. What is a function
and built-in function?
15. What is modular
programming?
16. What is a static
function?
17. Why should I
prototype a function?
18. When would you use
a pointer to a function?
19.
How do you use a pointer to a
function?
20.
Explain Stack winding.
No comments:
Post a Comment