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 is the output of the following program?
int y[4] = {6, 7, 8, 9}; 
int *ptr = y  + 2; 
printf("%d\n", ptr[ 1 ] );

Segmentation Fault

7

8

9

Question 3. char txt [20] = "Hello world!\0";
How many bytes are allocated by the definition above?

11 bytes

12 bytes

13 bytes

20 bytes

Question 4. what is the correct way to increment the pointer ptr
void *ptr;
myStruct myArray[10];
ptr = myArray;

ptr = ptr + sizeof(myStruct);

++(int*)ptr;

ptr = ptr + sizeof(myArray);

ptr = ptr + sizeof(ptr);

Question 5. 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 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. Which one of the following declares - "A pointer to a function which receives an int pointer and returns float pointer"

float *(ptr)*int;

float *(*ptr)(int)

float *(*ptr)(int*)

float (*ptr)(int)

Question 8. 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 9. How many times the program will print "TechInfoGurus" ?
#include<stdio.h>

int main()
{
    printf("TechInfoGurus");
    main();
    return 0;
}

infinite number of times

ERROR : main() cant be called recursively

65535 times

Till stack doesn't overflow

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