Functions

21

Point out the error in the program

f(int a, int b)
{
    int a;
    a = 20;
    return a;
}
A. Missing parenthesis in return statement
B. The function should be defined as int f(int a, int b)
C. Redeclaration of a
D. None of above

22

What will be the output of the program?

#include<stdio.h>
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;
}
A. 5.000000
B. 3.000000
C. Garbage value
D. 4.000000

23

What will be the output of the program?

#include<stdio.h>
int fun(int i)
{
    i++;
    return i;
}

int main()
{
    int fun(int);
    int i=3;
    fun(i=fun(fun(i)));
    printf("%d\n", i);
    return 0;
}
A. 5
B. 4
C. Error
D. Garbage value

24

What will be the output of the program?

#include<stdio.h>
int fun(int(*)());

int main()
{
    fun(main);
    printf("Hi\n");
    return 0;
}
int fun(int (*p)())
{
    printf("Hello ");
    return 0;
}
A. Infinite loop
B. Hi
C. Hello Hi
D. Error

25

If int is 2 bytes wide.What will be the output of the program?

#include<stdio.h>
void fun(char**);

int main()
{
    char *argv[] = {"ab", "cd", "ef", "gh"};
    fun(argv);
    return 0;
}
void fun(char **p)
{
    char *t;
    t = (p+= sizeof(int))[-1];
    printf("%s\n", t);
}
A. ab
B. cd
C. ef
D. gh