C Programming 70 MCQs
C Programming 70 MCQs
A) Dennis Ritchie
B) James Gosling
C) Bjarne Stroustrup
D) Guido van Rossum
Answer: A) Dennis Ritchie
A) Object-oriented
B) Procedural
C) Functional
D) Logic-based
Answer: B) Procedural
A) 1name
B) name1
C) name@123
D) #name
Answer: B) name1
A) :
B) .
C) ;
D) ,
Answer: C) ;
A) 2
B) 4
C) Compiler-dependent
D) 8
Answer: C) Compiler-dependent
A) for
B) while
C) do-while
D) All of the above
Answer: D) All of the above
A) True
B) False
C) Error
D) None
Answer: B) False
A) break
B) continue
C) goto
D) return
Answer: B) continue
A) for
B) while
C) do-while
D) None of the above
Answer: C) do-while
A) break
B) continue
C) goto
D) switch
Answer: D) switch
A) print()
B) printf()
C) cin
D) cout
Answer: B) printf()
A) auto
B) static
C) register
D) mutable
Answer: D) mutable
A) <conio.h>
B) <stdlib.h>
C) <stdio.h>
D) <math.h>
Answer: C) <stdio.h>
A) int
B) void
C) float
D) None of the above
Answer: A) int
A) Value of variable
B) Address of variable
C) Both A and B
D) None
Answer: B) Address of variable
17. Which operator is used to access the value at the address of a pointer?
A) *
B) &
C) ->
D) None
Answer: A) *
A) Value of x
B) Address of x
C) Garbage value
D) Error
Answer: B) Address of x
A) int *ptr;
B) float *ptr;
C) void ptr;
D) char *ptr;
Answer: C) void ptr
A) Address 0
B) Garbage address
C) Undefined
D) None of the above
Answer: A) Address 0
A) 0
B) 1
C) -1
D) None
Answer: A) 0
A) strcat()
B) strcmp()
C) strlen()
D) strcpy()
Answer: A) strcat()
A) <stdio.h>
B) <string.h>
C) <stdlib.h>
D) None
Answer: B) <string.h>
A) fopen("file.txt", "r");
B) open("file.txt", "r");
C) file_open("file.txt");
D) None
Answer: A) fopen("file.txt", "r");
27. What is the return value of fopen() if the file cannot be opened?
A) EOF
B) NULL
C) 0
D) -1
Answer: B) NULL
A) fgetc()
B) fread()
C) getc()
D) All of the above
Answer: A) fgetc()
A) open()
B) fopen()
C) fileopen()
D) None
Answer: B) fopen()
A) NULL
B) EOF
C) file pointer
D) None
Answer: A) NULL
36. Which keyword is used to prevent a function from modifying its arguments in C?
A) const
B) static
C) void
D) None
Answer: A) const
A) 2
B) 4
C) 8
D) Compiler-dependent
Answer: B) 4
A) int arr[10][20];
B) int arr(10, 20);
C) int arr{10, 20};
D) None
Answer: A) int arr[10][20];
A) 0
B) NULL
C) Garbage
D) Undefined
Answer: C) Garbage
A) strlen()
B) strlength()
C) sizeof()
D) strlen_len()
Answer: A) strlen()
41. Which of the following is not a valid way to access the value of a pointer?
A) *ptr
B) ptr*
C) &ptr
D) All are valid
Answer: C) &ptr
A) 0
B) 1
C) void
D) None
Answer: A) 0
A) Exit a loop
B) Skip the remaining iteration
C) Continue the loop
D) None
Answer: A) Exit a loop
A) fwrite()
B) fprintf()
C) putchar()
D) None
Answer: B) fprintf()
A) 2
B) 2.5
C) 0
D) 3
Answer: A) 2
A) Pointer
B) Array
C) Function
D) None
Answer: D) None
A) 4 bytes
B) 8 bytes
C) 16 bytes
D) 32 bytes
Answer: B) 8 bytes
49. Which of the following is a valid way to return a value from a function?
A) return value;
B) return address;
C) return pointer;
D) All of the above
Answer: D) All of the above
A) &&
B) &
C) |
D) ^
Answer: B) &
A) 127
B) 255
C) 32767
D) 65535
Answer: B) 255
A) +
B) *
C) ()
D) &&
Answer: C) ()
A) %d
B) %f
C) %c
D) %s
Answer: B) %f
A) int a;
B) float b;
C) double c;
D) char d;
Answer: B) float b;
A) Exits a loop
B) Exits a function
C) Continues to the next iteration
D) None
Answer: B) Exits a function
A) malloc()
B) calloc()
C) realloc()
D) All of the above
Answer: D) All of the above
65. What is the size of the `double` data type in most C compilers?
A) 4 bytes
B) 8 bytes
C) 2 bytes
D) Compiler-dependent
Answer: B) 8 bytes
A) rand()
B) random()
C) randint()
D) None
Answer: A) rand()
A) int (*ptr)();
B) int *ptr();
C) int *(*ptr);
D) None
Answer: A) int (*ptr)();
A) auto
B) register
C) extern
D) static
Answer: A) auto
70. What will the following code output?
`printf("%d", sizeof('A'));`
A) 1
B) 2
C) 4
D) 8
Answer: C) 4