Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. What is the output of code given below if these two files are linked and run?
in file test.c

  1.     #include <stdio.h>
  2.     #include "test.h"
  3.     int main()
  4.     {
  5.         i = 10;
  6.         printf("%d ", i);
  7.         foo();
  8.     }
  9.  
  10.     in file test1.c
  11.     #include <stdio.h>
  12.     #include "test.h"
  13.     int foo()
  14.     {
  15.         printf("%dn", i);
  16.     }
  17.  
  18.     in file test.h
  19.     #include <stdio.h>
  20.     #include <stdlib.h>
  21.     static int i;

a) 1 0 0
b) 0 0
c) 10 10
d) None of the mentioned

View Answer

Answer: d [Reason:] None.

2. Functions have static qualifier for its declaration by default.
a) true
b) false
c) Depends on the compiler
d) Depends on the standard

View Answer

Answer: b [Reason:] None.

3. Is initialisation mandatory for local static variables?
a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         foo();
  5.         foo();
  6.     }
  7.     void foo()
  8.     {
  9.         int i = 11;
  10.         printf("%d ", i);
  11.         static int j = 12;
  12.         j = j + 1;
  13.         printf("%dn", j);
  14.     }

a) 11 12 11 12
b) 11 13 11 14
c) 11 12 11 13
d) Compile time error

View Answer

Answer: b [Reason:] None.

5. Assignment statements assigning value to local static variables are executed only once
a) true
b) false
c) Depends on the code
d) None of the mentioned

View Answer

Answer: b [Reason:] None.

6. What is the format identifier for “static a = 20.5;”?
a) %s
b) %d
c) %f
d) Illegal declaration due to absence of data type

View Answer

Answer: b [Reason:] None.

7. Which of the following is true for static variable?
a) It can be called from another function.
b) It exists even after the function ends.
c) It can be modified in another function by sending it as a parameter.
d) All of the mentioned

View Answer

Answer: b [Reason:] None.

8. Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     void func();
  3.     int main()
  4.     {
  5.         static int b = 20;
  6.         func();
  7.     }
  8.     void func()
  9.     {
  10.         static int b;
  11.         printf("%d", b);
  12.     }

a) Output will be 0
b) Output will be 20
c) Output will be a garbage value
d) Compile time error due to redeclaration of static variable

View Answer

Answer: a [Reason:] None.

.woocommerce-message { background-color: #98C391 !important; }