Welcome to C Programming Quiz, Intermediate Level !!

Question 1. what is the output of the following program?
char* myFunc (char *ptr)
{
 ptr  += 3;
 return (ptr);
} 
int main()
{
 char *x, *y;
 x = "HELLO";
 y = myFunc (x);
 printf ("y = %s \n", y);
 return 0;
}

y = HELLO

y = ELLO

y = LLO

y = LO

Question 2. 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

Question 3. what will be the output of the following program?
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);

12,10,11,13

22,10,11,13

12,11,11,11

Undefined Behavior

Question 4. which one of the following declares "A pointer to an array of three chars"?

char *ptr[3]();

char (*ptr)*[3];

char (*ptr[3])();

char (*ptr)[3];

Question 5. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]

((((a+i)+j)+k)+l)

*(*(*(*(a+i)+j)+k)+l)

(((a+i)+j)+k+l)

((a+i)+j+k+l)

Question 6. How many times the while loop will get executed if a short int is 2 byte wide?
#include<stdio.h>
int main()
{
    int j=1;
    while(j <= 255)
    {
        printf("%c %d\n", j, j);
        j++;
    }
    return 0;
}

infinite number of times

255 times

256 times

254 times

Question 7. How many times "TechInfoGurus" is get printed?
#include<stdio.h>
int main()
{
    int x;
    for(x=-1; x<=10; x++)
    {
        if(x < 5)
            continue;
        else
            break;
        printf("TechInfoGurus");
    }
    return 0;
}

infinite number of times

11

0

10

Question 8. 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 9. What does x mean in this code sample ?
typedef char (*(*arrfptr[3])())[10];
arrfptr x;

x is a pointer

x is an array of three pointer

x is an array of three function pointers

error in declaration of x

Question 10. Assuming a short is two bytes long, what will be printed by the following code sample?
 short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} }; 
 printf( "%d\n", sizeof( testarray ) );

It will not compile because not enough initializers are given.

6

12

24