Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MCQ of C

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

MCQ of C Programming [ 1 x 10 =10]

1. What is the result of logical or relational expression in C?


a) True or False
b) 0 or 1
c) 0 if an expression is false and any positive number if an expression is true
d) None of the mentioned

2. Which keyword is used to come out of a loop only for that iteration?
a) break b) continue c) return d) void
3. How many times i value is checked in the following C program?

#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}

a) 2

b) 3

c) 4

d) 1

4. In C, if you pass an array as an argument to a function, what actually gets passed?


a) Value of elements in an array.
b) First element in an array.
c) The address of first element in an array.
d) The address of last element in an array.

5. What will be the output of the following C code?

#include <stdio.h>

int main()

int c = 2 ^ 3;

printf("%d\n", c);
}

a) 1

b) 8

c) 9

d) 0

6. Which keyword can be used for coming out of recursion?

a) break

b) return

c) exit

d) both break and return

7. Which function is used to record input from file?


a) ftell()
b) fwrite()
c) fprintf()
d) fread()

8. Will the following C code compile without any error?

#include <stdio.h>
int main()
{
for (int k = 0; k < 10; k++);
return 0;
}

a) Yes

b) No

c) Depends on the C standard implemented by compilers

d) Error
9. What is the function of the mode ‘ w+’?

a) create text file for writing, discard previous contents if any

b) create text file for update, discard previous contents if any

c) create text file for writing, do not discard previous contents if any

d) create text file for update, do not discard previous contents if any

10. What is meant by ‘a’ in the following C operation?


fp = fopen("Random.txt", "a");
a) Attach
b) Append
c) Apprehend
d) Add

You might also like