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

9/12

Page

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

What will be the output of the following C code?
#include <stdio.h>
int *m();
void main()
{
    int *k = m();
    printf("hello ");
    printf("%d", k[0]);
}
int *m()
{
    int a[2] = {5, 8};
    return a;
}

Select an option to see the answer and solution.

What is #include directive?

Select an option to see the answer and solution.

What is #include <stdio.h>?

Select an option to see the answer and solution.

If storage class is not specified for a local variable, then the default class will be auto.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following C code (without linking the source file in which ary1 is defined)?
#include <stdio.h>
int main()
{
    extern ary1[];
    printf("scope rules\n");
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of the following is a correct format for declaration of function?

Select an option to see the answer and solution.

Automatic variables are allocated space in the form of a . . . . . . . .

Select an option to see the answer and solution.

The value obtained in the function is given back to main by using . . . . . . . . keyword.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the x in the following C code?
#include <stdio.h>
void main()
{
    int x;
}

Select an option to see the answer and solution.

What linkage does automatic variables have?

Select an option to see the answer and solution.

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

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(), f();
    f();
}
void foo()
{
    printf("2 ");
}
void f()
{
    printf("1 ");
    foo();
}

Select an option to see the answer and solution.

Which of the following names for files not accepted?

Select an option to see the answer and solution.

If #include is used with file name in angular brackets.

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();
    void m()
    {
        printf("hi");
    }
}

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();
    printf("1 ");
    foo();
}
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>
static int x = 5;
void main()
{
    int x = 9;
    {
        x = 4;
    }
    printf("%d", x);
}

Select an option to see the answer and solution.