Welcome to C Programming Quiz, Randomly Selected !!

Question 1. Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");

reading

writing

appending

read and write

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

11 bytes

12 bytes

13 bytes

20 bytes

Question 3. 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 4. what will be the output of the following program
#include<stdio.h>
int fun(int **ptr);

int main()
{
    int i=10;
    const int *ptr = &i;
    fun(&ptr);
    return 0;
}
int fun(int **ptr)
{
    int j = 223;
    int *temp = &j;
    printf("Before changing ptr = %5x\n", *ptr);
    const *ptr = temp;
    printf("After changing ptr = %5x\n", *ptr);
    return 0;
}

address of i
     address of j

10
     223

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

garbage value

Question 5. what is the output of the following code sample?
#include <stdio.h>
int i; 
void increment( int i ) 
{ 
   i++  ; 
} 

int main() 
{ 
   for( i = 0; i < 10; increment( i ) ) 
   { 
   } 
   printf("i=%d\n", i); 
   return 0; 
}

it wont compile at all

i=9

i=10

wont print anything

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

* (asterisk)

| (pipeline)

- (hyphen)

_ (underscore)

Question 7. 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 8. 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 9. 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 10. 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)