Welcome to C Programming Quiz, Randomly Selected !!

Question 1. What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

union employee
{
    char name[15];
    int age;
    float salary;
};
const union employee e1;

int main()
{
    strcpy(e1.name, "K");
    printf("%s %d %f", e1.name, e1.age, e1.salary);
    return 0;
}

Error: RValue required

Error: cannot convert from 'const int *' to 'int *const'

Error: LValue required in strcpy

no error

Question 2. How will you free the memory allocated by the following program?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4

int main()
{
    int **p, i, j;
    p = (int **) malloc(MAXROW * sizeof(int*));
    return 0;
}

memfree(int p)

dealloc(p)

malloc(p, 0)

free(p)

Question 3. In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;

integer

integer pointer

error in declaration

none of the above

Question 4. What is the purpose of fflush() function.

flushes all streams and specified streams.

flushes only specified stream.

flushes input/output buffer.

flushes file buffer.

Question 5. what will be output of the following code sample
int x = 0; 
for ( ; ; ) 
{ 
 if (x++   == 4)
  break; 
 continue; 
} 
printf("x=%d\n", x);

x=0

x=1

x=5

x=4

Question 6. what is the output of the following code sample?
int x = 0; 
for (x=1; x<4; x++); 
printf("x=%d\n", x);

x=0

x=4

x=5

no output, it will loop forever

Question 7. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

The element will be set to 0.

The compiler would report an error.

The program may crash if some important data gets overwritten.

The array size would appropriately grow.

Question 8. Which of the following special symbol allowed in a variable name?

* (asterisk)

| (pipeline)

- (hyphen)

_ (underscore)

Question 9. In the following program where is the variable a getting defined and where it is getting declared?
#include<stdio.h>
int main()
{
    extern int a;
    printf("%d\n", a);
    return 0;
}
int a=20;

extern int a is declaration, int a = 20 is the definition

int a = 20 is declaration, extern int a is the definition

int a = 20 is definition, a is not defined

a is declared, a is not defined

Question 10. what will be the output of the following program
#include<stdio.h>
#include<stdarg.h>
void fun(char *msg, ...);

int main()
{
    fun("TechInfoGurus", 1, 4, 7, 11, 0);
    return 0;
}
void fun(char *msg, ...)
{
    va_list ptr;
    int num;
    va_start(ptr, msg);
    num = va_arg(ptr, int);
    num = va_arg(ptr, int);
    printf("%d", num);
}

TechInfoGurus 1 7 11 0

1

4

7