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

3/12

Page

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

Which of the following is a complete function?

Select an option to see the answer and solution.

What will be printed when this program is executed?
int f(int x)
{
   if(x <= 4)
      return x;
   return f(--x);
}
void main()
{
   printf("%d ", f(7)); 
}

Select an option to see the answer and solution.

The recursive functions are executed in a ...........

Select an option to see the answer and solution.

The function scanf() returns .........

Select an option to see the answer and solution.

Functions have ..........

Select an option to see the answer and solution.

Which of the following function calculates the square of 'x' in C?

Select an option to see the answer and solution.

When a function is recursively called all the automatic variables are stored in a ..........

Select an option to see the answer and solution.

char* myfunc(char *ptr)
{
   ptr+=3;
   return(ptr);
}

void main()
{
   char *x, *y;
   x = "EXAMVEDA";
   y = myfunc(x);
   printf("y=%s", y);
}

What will be printed when the sample code above is executed?

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
int main()
{
    printf("%s\n", foo(k, l));
    return 0;
}

Select an option to see the answer and solution.

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

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;
    printf("%d", x);
    {
        x = 4;
    }
    printf("%d", x);
}

Select an option to see the answer and solution.

Which part of the program address space is p stored in the following C code?
#include <stdio.h>
int *p = NULL;
int main()
{
    int i = 0;
    p = &i;
    return 0;
}

Select an option to see the answer and solution.

What would happen if you create a file stdio.h and use #include "stdio.h"?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Automatic variables are initialized to . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define MIN 0
#if defined(MIN) + defined(MAX)
#define MAX 10
#endif
int main()
{
    printf("%d %d\n", MAX, MIN);
    return 0;
}

Select an option to see the answer and solution.

Functions can return enumeration constants in C?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.