Vidyalelo
C Programming · all questions

Function
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

223

Questions

10/12

Page

Pick an option on a question to see the right answer and solution.

Which of the following cannot be static in C?

Select an option to see the answer and solution.

#include statement must be written . . . . . . . .

Select an option to see the answer and solution.

A local variable declaration with no storage class specified is by default . . . . . . . .

Select an option to see the answer and solution.

What is the problem in the following C declarations?
int func(int);
double func(int);
int func(float);

Select an option to see the answer and solution.

Is initialisation mandatory for local static variables?

Select an option to see the answer and solution.

Which of the following function declaration is illegal?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define A 1 + 2
#define B 3 + 4
int main()
{
    int var = A * B;
    printf("%d\n", var);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
double foo();
int main()
{
    foo();
    return 0;
}
foo()
{
    printf("2 ");
    return 2;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define foo(x, y) x / y + x
int main()
{
    int i = -6, j = 3;
    printf("%d ", foo(i + j, 3));
    printf("%d\n", foo(-3, 3));
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    foo();
    foo();
}
void foo()
{
    int i = 11;
    printf("%d ", i);
    static int j = 12;
    j = j + 1;
    printf("%d\n", j);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
register int x;
void main()
{
    printf("%d", x);
}

Select an option to see the answer and solution.

Functions can return structure in C?

Select an option to see the answer and solution.

What is the advantage of #define over const?

Select an option to see the answer and solution.

What is the default return type if it is not specified in function definition?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    void foo();
    void f()
    {
        foo();
    }
    f();
}
void foo()
{
    printf("2 ");
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    m();
    printf("%d", x);
}
int x;
void m()
{
    x = 4;
}

Select an option to see the answer and solution.

Functions in C are always . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    register static int i = 10;
    i = 11;
    printf("%d\n", i);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#include "printf"
void main()
{
    printf("hello");
}

Select an option to see the answer and solution.

Can variable i be accessed by functions in another source file?
#include <stdio.h>
int i;
int main()
{
    printf("%d\n", i);
}

Select an option to see the answer and solution.