Welcome to C Programming Quiz, Randomly Selected !!

Question 1. What will be the output of the program?

int main()
    const int x=5;
    const int *ptrx;
    ptrx = &x;
    *ptrx = 10;
    printf("%d\n", x);
    return 0;




garbage value

Question 2. Which bitwise operator is suitable for turning on a particular bit in a number?

&& operator

|| operator

& operator

| operator

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




read and write

Question 4. What will you do to treat the constant 3.14 as a long double?

use 3.14LD

use 3.14L

use 3.14DL

use 3.14LF

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

11 bytes

12 bytes

13 bytes

20 bytes

Question 6. Is there any difference between following declarations?
1:  extern int fun();
2:  int fun();

Both are identical

No difference, except extern int fun(); is probably in another file

int fun(); is overrided with extern int fun();

None of the above

Question 7. Which of the following cannot be checked in a switch-case statement?





Question 8. The function below has a flaw that may result in a serious error during some invocations. Which one of the following describes the deficiency illustrated above?
int fibonacci (int n)
 switch (n)
      return (fibonacci(n - 1) +  fibonacci(n - 2)); 
  case 1: 
  case 2: 
  return 1; 

For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes.

An error in the algorithm causes unbounded recursion for all values of n.

A break statement should be inserted after each case. Fall-through is not desirable here.

Since the default case is given first, it will be executed before any case matching n.

Question 9. What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile?
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
    int x=10, y=20;
    SWAP(x, y, int);
    printf("%d %d\n", x, y);
    return 0;

it compiles

compiles with a warning

not compile

compiles and prints nothing

Question 10. What will the function rewind() do?

Reposition the file pointer to a character reverse.

Reposition the file pointer stream to end of file.

Reposition the file pointer to begining of that line.

Reposition the file pointer to begining of file.