C Language Basic To Moderate MCQs :
Which function is used to print text in C?
A) print() B) echo() C) printf() D) println()
Answer: CWhich header file is needed for printf() and scanf()?
A) stdlib.h B) stdio.h C) conio.h D) string.h
Answer: BC language was developed by:
A) Dennis Ritchie B) James Gosling C) Bjarne Stroustrup D) Guido van Rossum
Answer: AWhat is the correct extension for a C program file?
A) .cpp B) .class C) .c D) .java
Answer: CWhich symbol is used for a single-line comment in C?
A) /* B) */ C) // D) #
Answer: CWhat is the default return type of a C function if not specified?
A) int B) float C) void D) char
Answer: AWhich of the following is a valid variable name in C?
A) 1data B) data_1 C) @data D) data-1
Answer: BWhich keyword is used to return a value from a function?
A) get B) return C) give D) break
Answer: BWhich of the following is not a data type in C?
A) int B) float C) real D) char
Answer: CWhich of the following symbols is used to end a statement in C?
A) , B) : C) ; D) .
Answer: CWhich function is used to take input from the user?
A) input() B) get() C) scanf() D) cin
Answer: CWhat is the size of an int in most 32-bit compilers?
A) 2 bytes B) 4 bytes C) 8 bytes D) 1 byte
Answer: BWhich keyword is used to define a constant in C?
A) constant B) define C) const D) final
Answer: CWhat will
printf("%d", 5 + 3);print?
A) 8 B) 5 + 3 C) Error D) None
Answer: AThe starting point of execution in a C program is:
A) start() B) init() C) main() D) execute()
Answer: CWhich of the following is a logical operator?
A) && B) ++ C) * D) %
Answer: AHow do you declare an integer variable in C?
A) int num; B) integer num; C) num int; D) num = int;
Answer: AWhat will
printf("%c", 'A' + 1);print?
A) A B) B C) C D) 65
Answer: BWhat does
%drepresent in printf()?
A) Integer B) Character C) Float D) String
Answer: AWhich function is used to clear the output screen in Turbo C?
A) clear() B) clrscr() C) reset() D) clean()
Answer: B
Which of the following is not a keyword in C?
A) auto B) main C) goto D) return
Answer: BWhich operator is used to get the remainder in division?
A) / B) % C) * D) //
Answer: BWhich of the following correctly declares an array in C?
A) int arr[]; B) int arr[5]; C) arr{5}; D) array arr(5);
Answer: BWhat is the correct syntax to assign value 10 to a variable x?
A) 10 = x; B) x == 10; C) x = 10; D) let x = 10;
Answer: CThe keyword
breakis used to:
A) Exit a loop or switch B) Skip one iteration C) End a function D) Pause execution
Answer: AWhat is the output of:
printf("%d", 2*3 + 4);
A) 10 B) 14 C) 12 D) 8
Answer: AWhich function is used to find the length of a string in C?
A) size() B) strlen() C) count() D) length()
Answer: BWhich library must be included to use
strlen()?
A) string.h B) stdlib.h C) stdio.h D) conio.h
Answer: AWhat is the output of:
printf("%d", 5/2);
A) 2.5 B) 2 C) 2.0 D) 3
Answer: BWhich operator is used for “AND” in C?
A) & B) && C) and D) ||
Answer: BWhat will
printf("%f", 10/4);print?
A) 2.5 B) 2.0 C) 2.000000 D) 2
Answer: DWhich of the following converts string to integer?
A) atoi() B) itoa() C) stoi() D) toint()
Answer: AThe
ifstatement is used for:
A) Repetition B) Decision making C) Input D) Output
Answer: BWhich loop executes at least once even if the condition is false?
A) for B) while C) do…while D) none
Answer: CWhich keyword is used to define a function in C?
A) func B) define C) void/int D) function
Answer: CWhat is the output of:
printf("%d", 5 == 5);
A) 1 B) 0 C) Error D) 5
Answer: AWhich format specifier is used for float values?
A) %d B) %f C) %lf D) %c
Answer: BWhat will
printf("%c", 'a' - 32);print?
A) a B) A C) b D) Error
Answer: BWhich keyword is used to include header files in C?
A) import B) include C) using D) require
Answer: BThe statement
#include <stdio.h>is a:
A) Preprocessor directive B) Compiler command C) Function D) Loop
Answer: AWhich of these is not a looping statement?
A) for B) if C) while D) do…while
Answer: BThe correct way to declare a pointer is:
A) int p; B) int p; C) pointer p; D) *int p;
Answer: AWhich of these is not a valid operator?
A) ++ B) – C) ** D) %
Answer: CWhat does
\nrepresent in a string?
A) Null B) Newline C) Tab D) Space
Answer: BWhich function is used to read a string from the user?
A) input() B) scanf() C) gets() D) read()
Answer: CWhat is the correct syntax of a for loop?
A) for(i=0;i<10;i++) B) for i<10 C) loop(i=0;10) D) repeat(10)
Answer: AWhat is the output of
printf("%d", sizeof(char));?
A) 2 B) 4 C) 1 D) 8
Answer: CThe operator used to access structure members is:
A) * B) . C) -> D) &
Answer: BWhich keyword is used to stop a loop?
A) stop B) end C) break D) halt
Answer: CWhat is the range of an 8-bit unsigned integer?
A) 0 to 127 B) 0 to 255 C) -128 to 127 D) -255 to 255
Answer: BWhich operator is used to assign a value?
A) == B) := C) = D) =>
Answer: CWhat is the output of
printf("%d", 3>2);?
A) 3 B) 2 C) 1 D) 0
Answer: CWhich keyword is used to continue to the next iteration?
A) break B) next C) continue D) skip
Answer: CWhich operator is used to perform multiplication?
A) x B) * C) mul D) #
Answer: BThe
elsepart of anifstatement executes when:
A) Condition is true B) Condition is false C) Always D) Never
Answer: BWhich function is used to allocate memory dynamically?
A) malloc() B) alloc() C) memory() D) new()
Answer: AWhich function is used to release allocated memory?
A) delete() B) free() C) remove() D) release()
Answer: BWhat does
EOFstand for?
A) End Of File B) End Of Function C) Exit On Fail D) End Of Format
Answer: AThe keyword
staticmeans:
A) Constant value B) Value preserved between calls C) External linkage D) Dynamic memory
Answer: BWhich operator is used to get the address of a variable?
A) * B) & C) @ D) #
Answer: B
Which of these is a valid C identifier?
A) int B) float C) my_var D) return
Answer: CWhat does
sizeof()operator do?
A) Returns the type name B) Returns the variable value C) Returns the memory size D) Returns the address
Answer: CWhich of these is a valid way to declare a character variable?
A) char ch; B) character ch; C) string ch; D) char = ch;
Answer: AWhat will
printf("%d", 10 != 5);print?
A) 0 B) 1 C) 10 D) Error
Answer: BWhat is the ASCII value of ‘A’?
A) 64 B) 65 C) 66 D) 67
Answer: BWhat will be the output of
printf("%d", 5%2);?
A) 1 B) 2 C) 0 D) 5
Answer: AWhich of these is not a looping construct?
A) while B) do C) for D) switch
Answer: DWhich symbol is used to start a preprocessor directive?
A) $ B) & C) # D) @
Answer: CWhich of the following is a conditional operator?
A) ++ B) ?: C) && D) ||
Answer: BWhat will
printf("%d", 5>3 && 3>2);print?
A) 0 B) 1 C) 2 D) Error
Answer: BWhat is the output of
printf("%d", 10/3);?
A) 3.333 B) 3 C) 4 D) 10
Answer: BWhat is the correct syntax of an
ifstatement?
A) if(condition) B) if condition C) if: condition D) if{condition}
Answer: AWhich of the following is not a storage class in C?
A) auto B) static C) register D) local
Answer: DWhich format specifier is used for double values?
A) %f B) %lf C) %d D) %c
Answer: BWhich keyword is used to declare a global variable?
A) global B) extern C) static D) register
Answer: BWhat does
return 0;in main() signify?
A) Successful execution B) Error occurred C) Infinite loop D) Function call
Answer: AWhich keyword is used to define constants in C?
A) define B) constant C) fixed D) const
Answer: DWhat is the correct syntax to read an integer using scanf()?
A) scanf(“%int”, &a); B) scanf(“%d”, a); C) scanf(“%d”, &a); D) scanf(“%c”, &a);
Answer: CWhat is the default value of an uninitialized local variable in C?
A) 0 B) Null C) Undefined/Garbage D) Empty
Answer: CWhich of the following correctly increments
xby 1?
A) x = x + 1; B) x++; C) ++x; D) All of the above
Answer: DWhich function is used to convert uppercase to lowercase?
A) tolower() B) lower() C) downcase() D) strlow()
Answer: AWhich function is used to compare two strings?
A) strcmp() B) compare() C) strmatch() D) equal()
Answer: AWhich of the following is not a bitwise operator?
A) & B) | C) && D) ^
Answer: CWhich symbol is used to dereference a pointer?
A) * B) & C) @ D) %
Answer: AWhat is the output of:
int a = 10;
printf("%d", ++a);
A) 9 B) 10 C) 11 D) Error
Answer: C
What will
printf("%d", a--);do?
A) Decrease a before printing B) Print and then decrease a C) Increase a D) Error
Answer: BWhich function is used to copy strings?
A) strcpy() B) copystr() C) strcopy() D) memcpy()
Answer: AHow many bytes does
charoccupy?
A) 1 B) 2 C) 4 D) 8
Answer: AWhich keyword is used to jump to a labeled statement?
A) break B) continue C) goto D) jump
Answer: CThe main() function returns which data type by default?
A) void B) int C) char D) float
Answer: BWhich header file contains mathematical functions like sqrt()?
A) math.h B) stdio.h C) conio.h D) string.h
Answer: AWhat is the correct syntax to declare an array of 5 integers?
A) int[5] arr; B) int arr[5]; C) arr int[5]; D) array arr[5];
Answer: BWhich function terminates a program immediately?
A) stop() B) end() C) exit() D) terminate()
Answer: CWhich operator is used to test equality?
A) = B) == C) := D) equals
Answer: BWhich of the following is a relational operator?
A) == B) ++ C) && D) %
Answer: AWhich loop checks the condition before execution?
A) do…while B) for C) while D) Both B and C
Answer: DWhich statement is used to end the program in C?
A) exit() B) stop() C) quit() D) break()
Answer: AWhat is the size of
floatin C (typically)?
A) 2 bytes B) 4 bytes C) 8 bytes D) 16 bytes
Answer: BWhat is the use of
#define?
A) To define a function B) To create a macro/constant C) To declare a variable D) To start main
Answer: BWhat does
%srepresent in printf()?
A) String B) Character C) Integer D) Float
Answer: A
Which of these is not a valid C data type?
A) int B) float C) bool D) double
Answer: CWhich keyword is used to include libraries in C?
A) include B) #include C) import D) add
Answer: BWhat is the use of the
continuestatement?
A) Exit loop B) Skip to next iteration C) Stop program D) Jump to main
Answer: BWhich of the following denotes a newline in C?
A) \r B) \t C) \n D) \
Answer: CWhich function is used to display formatted output?
A) output() B) display() C) printf() D) cout
Answer: CThe
main()function should always return:
A) float B) char C) int D) void
Answer: CWhat is the output of
printf("%d", 3*2+4/2);?
A) 8 B) 10 C) 7 D) 6
Answer: AWhich symbol is used for OR operation in C?
A) || B) | C) + D) or
Answer: AWhat is the correct way to define a constant in C?
A) const int a=10; B) define a 10; C) int const=10; D) fixed a=10;
Answer: AWhat will
printf("%d", sizeof(int));print on most 32-bit systems?
A) 2 B) 4 C) 8 D) 16
Answer: BWhich function is used to read a character from keyboard?
A) getch() B) getchar() C) read() D) get()
Answer: BWhat is the output of
'A' + 1?
A) B B) 66 C) Error D) A
Answer: BWhich function is used to copy memory blocks?
A) memcpy() B) strcpy() C) copy() D) blockcopy()
Answer: AWhich operator has the highest precedence?
A) + B) * C) () D) =
Answer: CWhich of the following is not a valid escape sequence?
A) \n B) \t C) \s D) \
Answer: CWhich keyword is used to make a function visible to other files?
A) static B) extern C) global D) public
Answer: BWhich format specifier is used for characters?
A) %s B) %c C) %d D) %f
Answer: BWhich loop executes 0 or more times?
A) while B) for C) do…while D) while and for
Answer: DThe statement
int a[5]={1,2,3};initializes remaining elements with:
A) 1 B) 2 C) 0 D) garbage
Answer: CWhich operator is used to perform division?
A) * B) % C) / D) //
Answer: CWhich function closes a file in C?
A) endfile() B) close() C) fclose() D) stop()
Answer: CWhat does
NULLrepresent in C?
A) Empty string B) 0 or no value C) False D) -1
Answer: BWhich keyword is used to define macros?
A) define B) macro C) const D) typedef
Answer: AWhich of these operators is unary?
A) + B) - C) ++ D) %
Answer: CWhich function is used to concatenate strings?
A) strcat() B) stradd() C) join() D) append()
Answer: AThe expression
a += b;is equivalent to:
A) a = a + b; B) a = b + 1; C) a = b; D) None
Answer: AWhich keyword is used to declare a function prototype?
A) extern B) prototype C) func D) declare
Answer: AWhich of these is not an arithmetic operator?
A) + B) - C) * D) &&
Answer: DWhat is the correct way to declare a 2D array?
A) int a[2][3]; B) int[2,3] a; C) array[2][3]; D) int a{2}{3};
Answer: AWhich function returns the length of a string?
A) strlen() B) size() C) length() D) count()
Answer: AWhat is the output of
printf("%d", 4>5);?
A) 4 B) 5 C) 1 D) 0
Answer: DWhich of these cannot be a variable name?
A) total B) _value C) 5num D) sum
Answer: CWhich keyword is used to declare an array?
A) var B) array C) None (type name used) D) arr
Answer: CWhat is the output of
'b' - 'a'?
A) 0 B) 1 C) 2 D) Error
Answer: BWhich operator is known as the “address-of” operator?
A) * B) & C) @ D) #
Answer: BWhat is the output of
printf("%d", 10<5);?
A) 0 B) 1 C) 10 D) Error
Answer: AWhich keyword is used to declare enumeration?
A) enum B) struct C) union D) typedef
Answer: AWhat does
%urepresent in printf()?
A) Unsigned integer B) Unicode C) Uppercase D) User value
Answer: AThe function
feof()checks for:
A) Start of file B) End of file C) Empty file D) Error
Answer: BWhich keyword is used for decision making?
A) if B) loop C) repeat D) switch
Answer: AWhich of these is not a valid loop?
A) do B) for C) repeat-until D) while
Answer: CWhich operator is used to increment by one?
A) ++ B) – C) += D) =+
Answer: AWhat is the maximum length of an identifier in C (standard)?
A) 31 B) 32 C) 63 D) 127
Answer: AThe operator
!is known as:
A) NOT B) AND C) OR D) XOR
Answer: AWhich function is used to open a file?
A) fopen() B) open() C) start() D) fileopen()
Answer: AWhat is the result of
5%10?
A) 0 B) 5 C) 10 D) Error
Answer: BWhich function reads formatted input from keyboard?
A) scanf() B) input() C) get() D) read()
Answer: AWhich format specifier prints an address?
A) %p B) %d C) %f D) %s
Answer: AWhich function is used to generate random numbers?
A) rand() B) random() C) getrand() D) rnd()
Answer: AWhich operator is used to combine conditions?
A) & B) | C) && or || D) %
Answer: CWhich keyword is used to define a structure?
A) struct B) class C) typedef D) object
Answer: AWhat does
break;do in a loop?
A) Ends the loop B) Skips one iteration C) Restarts loop D) Pauses
Answer: AWhich operator is used for pointer dereferencing?
A) * B) & C) -> D) .
Answer: AWhat will
printf("%d", 5>3 ? 10:20);print?
A) 10 B) 20 C) 5 D) Error
Answer: AWhich of these is a valid string literal?
A) ‘Hello’ B) Hello C) “Hello” D) (Hello)
Answer: CWhich function is used to find power in math.h?
A) pow() B) power() C) exp() D) sqrt()
Answer: AWhich data type can store large decimal numbers?
A) int B) float C) double D) char
Answer: CWhat will
printf("%d", !0);print?
A) 0 B) 1 C) -1 D) Error
Answer: BWhich operator is used to access members using pointer?
A) . B) -> C) * D) &
Answer: BWhat does
%xrepresent in printf()?
A) Decimal B) Hexadecimal C) Octal D) Binary
Answer: BWhat is the output of
printf("%o", 10);?
A) 10 B) 8 C) 12 D) Error
Answer: CWhich function is used to round a number?
A) round() B) floor() C) ceil() D) Both B and C
Answer: DThe function
fflush(stdout)is used to:
A) Close file B) Clear output buffer C) Refresh input D) None
Answer: BWhat is the return type of
sizeof?
A) int B) long C) size_t D) float
Answer: CWhat will
printf("%d", 5==5 && 5!=6);print?
A) 0 B) 1 C) 5 D) Error
Answer: BWhich of these is a user-defined data type?
A) struct B) int C) float D) char
Answer: AWhich function compares two characters?
A) strcmp() B) memcmp() C) stricmp() D) chrcmp()
Answer: AWhat is the default value of a static variable?
A) 0 B) 1 C) Null D) Garbage
Answer: AWhat is the return type of main() by default?
A) int B) void C) float D) None
Answer: AWhich function writes data to a file?
A) fwrite() B) fput() C) write() D) fdata()
Answer: AWhich operator combines both arithmetic and assignment?
A) += B) == C) = D) ++
Answer: AWhich function is used to read data from a file?
A) fread() B) read() C) fget() D) fdata()
Answer: AWhich function converts a string to float?
A) atof() B) atoi() C) itof() D) strtof()
Answer: AWhat is the result of
10 / 3.0?
A) 3 B) 3.0 C) 3.333333 D) Error
Answer: CWhat will
printf("%d", 10>>1);print?
A) 5 B) 10 C) 20 D) 2
Answer: AWhich function returns absolute value?
A) abs() B) fabs() C) value() D) mod()
Answer: AWhich operator is used to perform bitwise XOR?
A) ^ B) | C) & D) ~
Answer: AWhat does
%orepresent in printf()?
A) Octal B) Object C) Operator D) Overflow
Answer: AWhich function clears the console screen in C (Turbo)?
A) clrscr() B) clear() C) reset() D) clean()
Answer: AWhat will
printf("%d", 1 && 0);print?
A) 1 B) 0 C) True D) Error
Answer: BWhich of these is a valid comment syntax?
A) # Comment B) /* Comment */ C) <Comment> D) $ Comment
Answer: BWhat is the output of
printf("%c", 65);?
A) 65 B) A C) a D) Error
Answer: BWhich of these is a keyword in C?
A) select B) case C) switcher D) choose
Answer: BWhich function terminates the string in C?
A) ‘\0’ B) null C) \n D) end
Answer: AWhich operator is used to perform logical NOT?
A) ! B) ~ C) ^ D) &
Answer: AWhich function is used to convert a character to uppercase?
A) toupper() B) upper() C) cap() D) capitalize()
Answer: AWhat is the output of
printf("%d", 2<<1);?
A) 1 B) 2 C) 4 D) 8
Answer: CWhich operator is used to perform bitwise AND?
A) && B) & C) and D) %
Answer: BWhich function pauses the program until a key is pressed?
A) getch() B) getchar() C) pause() D) wait()
Answer: AWhich of these functions allocates memory?
A) malloc() B) calloc() C) realloc() D) All of these
Answer: DWhich data type can store true or false?
A) bool B) int C) _Bool D) char
Answer: CWhich function converts integer to string?
A) itoa() B) atoi() C) strint() D) tostr()
Answer: AWhich header file contains string functions?
A) string.h B) stdlib.h C) stdio.h D) conio.h
Answer: AWhich function compares memory blocks?
A) memcmp() B) strcmp() C) memcompare() D) checkmem()
Answer: AWhat is the output of
printf("%d", 2|4);?
A) 2 B) 4 C) 6 D) 8
Answer: CWhich function is used to get the current file position?
A) ftell() B) fseek() C) pos() D) tell()
Answer: AWhich keyword prevents modification of a variable?
A) fixed B) const C) static D) final
Answer: BWhich function repositions file pointer?
A) fseek() B) ftell() C) seek() D) setpos()
Answer: AWhich operator is used for assignment?
A) == B) = C) := D) =>
Answer: BWhich header file contains memory management functions?
A) stdlib.h B) string.h C) stdio.h D) conio.h
Answer: A
C Language Moderate MCQs :
What is the output of
printf("%d", sizeof('A'));?
A) 1 B) 2 C) 4 D) Depends on compiler
Answer: CWhich of the following is a valid pointer declaration?
A) int ptr; B) int ptr; C) *int ptr; D) int &ptr;
Answer: AWhat will
printf("%s", NULL);do?
A) Print “NULL” B) Print nothing C) Cause a segmentation fault D) Compile error
Answer: CWhich function dynamically allocates memory?
A) malloc() B) calloc() C) realloc() D) All of the above
Answer: DThe operator
->is used with:
A) Arrays B) Structures via pointers C) Functions D) Loops
Answer: BWhich function releases dynamically allocated memory?
A) delete() B) free() C) remove() D) dispose()
Answer: BWhat is the output of
printf("%d", 5==5==5);?
A) 0 B) 1 C) Error D) Undefined
Answer: BWhat is the output of
sizeof(3.14f)?
A) 2 B) 4 C) 8 D) 16
Answer: BWhich of the following is not a storage class in C?
A) static B) register C) auto D) global
Answer: DWhat is the output of
printf("%d", 10%(-3));?
A) -1 B) 1 C) -2 D) Undefined
Answer: BWhich function reads a line from file until newline?
A) fgets() B) fread() C) gets() D) readline()
Answer: AWhich of these statements is true about arrays in C?
A) Index starts at 1 B) Size can change dynamically C) Index starts at 0 D) Arrays can’t store strings
Answer: CWhat is the output of
printf("%d", ++*p);whereppoints to integer 5?
A) 5 B) 6 C) 7 D) Error
Answer: BWhat is the size of an empty structure in C?
A) 0 B) 1 C) Undefined D) Depends on compiler
Answer: BWhat is the output of
'A' + 32?
A) ‘a’ B) 97 C) ‘A’ D) Both A and B
Answer: DWhich of the following correctly initializes a pointer to a string literal?
A) char *s = “Hello”; B) char s = “Hello”; C) char s[] = *”Hello”; D) *s = “Hello”;
Answer: AWhat is the output of
printf("%d", strcmp("abc","abd"));?
A) 0 B) 1 C) -1 D) Garbage
Answer: CWhich function is used to set the position of file pointer?
A) ftell() B) fseek() C) rewind() D) reposition()
Answer: BThe default return type of a function without type declaration is:
A) int B) void C) float D) Undefined
Answer: AWhat will
int x = 5, y = x++;result in?
A) x=6, y=6 B) x=6, y=5 C) x=5, y=6 D) Error
Answer: BWhich operator cannot be overloaded in C?
A) + B) -> C) = D) ?:
Answer: DThe expression
a == b == cis evaluated as:
A) (a == b) == c B) a == (b == c) C) a == b == c D) Undefined
Answer: AWhich statement correctly opens a file for both reading and writing?
A) fopen(“test.txt”, “rw”); B) fopen(“test.txt”, “r+”); C) fopen(“test.txt”, “rw+”); D) fopen(“test.txt”, “wr”);
Answer: BWhich of the following is a pointer to a function?
A) int (*p)(); B) int *p(); C) *int p(); D) int &(p)();
Answer: AWhat is the result of
5 & 3?
A) 1 B) 5 C) 7 D) 0
Answer: AWhat does the function
strcpy(dest, src)do?
A) Copies src to dest B) Appends src C) Compares both D) Returns length
Answer: AWhat does the expression
*(*(arr + 1) + 2)access?
A) arr[2][1] B) arr[1][2] C) arr[1][1] D) arr[2][2]
Answer: BWhat is the output of
printf("%d", !5);?
A) 5 B) 0 C) 1 D) -5
Answer: BWhich keyword is used to stop recursion?
A) exit B) stop C) return D) break
Answer: CWhat is the output of
printf("%d", 2 << 2);?
A) 4 B) 6 C) 8 D) 2
Answer: CWhich operator is used for conditional expression?
A) if B) ?: C) switch D) &&
Answer: BWhich statement is true about
staticvariables?
A) They can’t retain value B) They retain value between calls C) They are global D) They are extern by default
Answer: BWhat will be the output of:
int i=0;
while(i<3)
printf("%d",i++);
A) 012 B) 123 C) 0 1 2 D) Error
Answer: A
What is the value of
sizeof(int*)on a 64-bit system?
A) 2 B) 4 C) 8 D) 16
Answer: CWhich function is used to allocate zero-initialized memory?
A) malloc() B) calloc() C) realloc() D) free()
Answer: BWhat will be the output of
printf("%d", 4>>1);?
A) 2 B) 4 C) 8 D) 1
Answer: AWhich library function compares two memory blocks?
A) memcmp() B) strcmp() C) compare() D) check()
Answer: AWhat is the correct declaration of an array of pointers?
A) int a[5]; B) int a[5]; C) int (*a)[]; D) int *a();
Answer: AWhat is the purpose of
fflush(stdin);?
A) Clears output buffer B) Clears input buffer C) Flushes both D) Undefined behavior
Answer: DWhich of the following statements is true?
A) char arrays can hold multiple words
B) Strings in C are null-terminated
C) Strings are stored as objects
D) String length is unlimited
Answer: BWhat will
printf("%p", main);print?
A) Address of main() B) Name of function C) Garbage D) Error
Answer: AWhat is the result of
sizeof("Hello")?
A) 5 B) 6 C) 7 D) 8
Answer: BThe default value of an automatic variable is:
A) 0 B) Undefined (garbage) C) Null D) Random
Answer: BWhich function is used to move file pointer to the beginning?
A) fseek(fp,0,SEEK_SET); B) rewind(fp); C) reset(fp); D) A or B
Answer: DWhat is the output of
printf("%d", sizeof(printf("C")));?
A) 1 B) 2 C) 4 D) Compiler dependent
Answer: DThe maximum number of dimensions an array can have in C is:
A) 2 B) 3 C) 5 D) Compiler dependent
Answer: DWhich function is used to compare two strings without case sensitivity?
A) strcmpi() B) strcasecmp() C) stricmp() D) Both A and B
Answer: DWhat is the output of the following?
int a=5;
printf("%d", a+++a);
A) 10 B) 11 C) 9 D) Undefined
Answer: D
Which header file defines the function
exit()?
A) stdio.h B) stdlib.h C) conio.h D) process.h
Answer: BWhat will
printf("%d", -10 % 3);print?
A) 1 B) -1 C) 2 D) -2
Answer: B
What is the output of
int x = 10;
printf("%d", x++ + ++x);
A) 21 B) 22 C) Undefined D) 20
Answer: C
Which function is used to reposition the file pointer to the end of a file?
A) fseek(fp, 0, SEEK_END); B) rewind(fp); C) fclose(fp); D) ftell(fp);
Answer: AWhat is the output of
printf("%d", printf("C"));
A) C1 B) C2 C) 1C D) Depends on compiler
Answer: A
The function
realloc(ptr, new_size)is used to:
A) Reallocate memory B) Free memory C) Copy memory D) Reset memory
Answer: AWhich function returns the string length excluding the null character?
A) strlen() B) sizeof() C) strsize() D) count()
Answer: AWhich header must be included for
toupper()?
A) ctype.h B) string.h C) stdlib.h D) stdio.h
Answer: AWhat will the following code print?
int i = 0;
for (; i < 5; i++);
printf("%d", i);
A) 0 B) 4 C) 5 D) Error
Answer: C
In C, which statement is correct about pointers and arrays?
A) Arrays are pointers B) Pointers and arrays are unrelated
C) Array name is a constant pointer D) Array name is a variable
Answer: CWhich operator has the lowest precedence in C?
A) = B) ++ C) * D) ()
Answer: AWhich header defines the function
malloc()?
A) stdlib.h B) stdio.h C) memory.h D) malloc.h
Answer: AWhich function converts an integer to string safely in C?
A) itoa() B) sprintf() C) snprintf() D) strint()
Answer: CWhat is the output of
int a = 5;
printf("%d", a += (a *= 2) + 1);
A) 16 B) 10 C) 17 D) Undefined
Answer: A
What is the effect of
externkeyword?
A) Defines a new variable B) Declares a variable defined elsewhere C) Makes variable private D) Frees variable
Answer: BWhat does the statement
int (*p)[5];mean?
A) p is a pointer to an array of 5 ints B) Array of 5 int pointers C) Array pointer D) Function pointer
Answer: AWhich format specifier displays a float in exponential form?
A) %f B) %e C) %g D) %lf
Answer: BWhat will this program output?
int x = 5;
if (x = 0)
printf("Zero");
else
printf("Non-zero");
A) Zero B) Non-zero C) Error D) None
Answer: B
Which of these correctly defines a structure variable?
A) struct student s; B) structure student s; C) student struct s; D) define student s;
Answer: AWhat is the result of
5 | 2?
A) 7 B) 10 C) 2 D) 5
Answer: AWhich function reads formatted input from a file?
A) scanf() B) fscanf() C) readf() D) inputf()
Answer: BThe pointer returned by
malloc()is of type:
A) void * B) int * C) char * D) generic *
Answer: AWhat is the output of
int a = 10;
printf("%d", a == 10 ? 100 : 200);
A) 100 B) 200 C) 10 D) Error
Answer: A
Which statement is used to handle errors in file operations?
A) ferror() B) perror() C) feof() D) All of these
Answer: DThe value of
sizeof(double)on most 64-bit compilers is:
A) 4 B) 6 C) 8 D) 10
Answer: CWhich function returns a pointer to the first occurrence of a character in a string?
A) strchr() B) strstr() C) strrchr() D) findchar()
Answer: AWhat will be the output of
int a=2,b=3;
printf("%d", a+++b);
A) 5 B) 6 C) Syntax error D) Undefined
Answer: A
Which function in
<math.h>returns the remainder of division?
A) fmod() B) mod() C) rem() D) remain()
Answer: AWhich keyword makes a variable visible only within the same source file?
A) static B) extern C) const D) register
Answer: AWhat is the output of
printf("%c", "Hello"[1]);
A) H B) e C) l D) o
Answer: B
What will happen if you
free()a NULL pointer?
A) Segmentation fault B) Undefined behavior C) No effect D) Compiler error
Answer: CWhich function sets all bytes in a block of memory to zero?
A) bzero() B) memset() C) clear() D) memclr()
Answer: BWhat is the return type of
sizeofoperator?
A) int B) unsigned int C) size_t D) long
Answer: CWhat does this loop print?
for(int i=0; i<3; i++)
for(int j=0; j<2; j++)
printf("*");
A) 6 asterisks B) 3 asterisks C) 2 asterisks D) Error
Answer: A
Which of the following is not valid in C?
A) void main() B) int main(void) C) main() D) int main(int argc, char *argv[])
Answer: AThe keyword
typedefis used to:
A) Allocate memory B) Define alias for data types C) Define macros D) None
Answer: BWhat is the output of
int x = 1;
printf("%d", x << 3);
A) 8 B) 3 C) 2 D) 1
Answer: A
What is the output of
int a=1;
while(a<=3)
printf("%d", a++);
A) 1 2 3 B) 123 C) 0 1 2 D) Infinite loop
Answer: B
Which function compares two strings up to n characters?
A) strncmp() B) strcomp() C) strncm() D) strmatch()
Answer: AWhat is the value of expression
sizeof(4.5)?
A) 4 B) 8 C) 2 D) 10
Answer: BWhich header defines mathematical constants like M_PI?
A) math.h B) const.h C) stdlib.h D) stdio.h
Answer: AWhat will be the output of
char s[]="C";
printf("%d", sizeof(s));
A) 1 B) 2 C) 3 D) Undefined
Answer: B
Which of these is a correct recursive factorial function prototype?
A) int fact(int n); B) fact(int n); C) int fact(); D) int fact(int n, int r);
Answer: AWhat is the value of
printf("%d", strcmp("AB", "AC"));?
A) 0 B) 1 C) -1 D) 2
Answer: CWhich pointer always contains the current function’s stack frame base?
A) stack pointer B) frame pointer C) base pointer D) both B and C
Answer: DWhat does
fprintf(fp, "%s", str);do?
A) Writes string to file B) Reads string from file C) Formats file D) None
Answer: AWhat is printed by
int x = 2, y = 3;
printf("%d", x && y || 0);
A) 0 B) 1 C) 2 D) 3
Answer: B
What is the output of
printf("%d", (int)3.99);?
A) 3 B) 4 C) 3.99 D) Error
Answer: AWhat will
printf("%c", *"CProgramming");print?
A) C B) P C) Error D) Nothing
Answer: AWhich function returns current system time?
A) time() B) gettime() C) systemtime() D) clock()
Answer: AWhich preprocessor directive is used to avoid multiple inclusions of header files?
A) #ifndef / #define B) #protect C) #onceonly D) #safe
Answer: AWhich function converts a string to long int?
A) atol() B) atoi() C) strtol() D) Both A and C
Answer: D
What is the output of
int a = 5;
printf("%d", a++ + ++a);
A) 11 B) 12 C) Undefined D) 10
Answer: C
What does the
continuestatement do in a loop?
A) Exits the loop B) Skips remaining statements and starts next iteration C) Restarts loop D) Ends program
Answer: BWhich function is used to open a file in C?
A) openfile() B) fopen() C) fileopen() D) start()
Answer: BWhat will be the output of
char str[] = "C";
printf("%d", sizeof(str));
A) 1 B) 2 C) 3 D) 4
Answer: B
Which storage class makes a variable retain its value between function calls?
A) auto B) register C) static D) extern
Answer: CWhich operator is used to access structure members through a pointer?
A) . B) -> C) & D) *
Answer: BWhat is the output of
int x=2, y=3;
printf("%d", (x>y)?x:y);
A) 2 B) 3 C) 0 D) Error
Answer: B
Which keyword prevents modification of a variable?
A) constant B) static C) const D) immutable
Answer: CWhich function is used to copy n characters from one string to another?
A) strncpy() B) strcpy() C) strcopy() D) memcpy()
Answer: AWhich data type has the highest precision?
A) float B) double C) long double D) int
Answer: CThe statement
int (*fun)(int, int);means:
A) fun is a pointer to function B) fun is a function C) fun is an array D) fun is a macro
Answer: AWhat is the output of
printf("%d", 10/4);
A) 2.5 B) 2 C) 3 D) Error
Answer: B
The correct way to dynamically allocate an array of 5 integers:
A) int p = malloc(5sizeof(int)); B) int p = malloc(5); C) int p[5]; D) malloc(5,int);
Answer: AWhich function is used to get the current position of file pointer?
A) fseek() B) ftell() C) rewind() D) feof()
Answer: BWhich of these is not a valid identifier?
A) _abc B) 1num C) value D) printf1
Answer: BWhat is the size of
inton most 32-bit compilers?
A) 2 B) 4 C) 8 D) 6
Answer: BWhich function terminates a program immediately?
A) end() B) stop() C) exit() D) terminate()
Answer: CWhich operator is used to allocate memory dynamically?
A) new B) malloc() C) alloc() D) getmem()
Answer: BWhich function is used to concatenate two strings?
A) strcat() B) append() C) join() D) stradd()
Answer: AWhat is the output of
int a=5;
printf("%d", a==5);
A) 5 B) 1 C) 0 D) Error
Answer: B
Which keyword is used to include header files in C?
A) include B) #include C) import D) use
Answer: BWhich function is used to find a substring in another string?
A) strstr() B) strchr() C) strcmp() D) strcpy()
Answer: AWhich operator checks both sides before executing second condition?
A) & B) && C) | D) ||
Answer: BWhat is the output of
int x=5;
printf("%d", ++x + x++);
A) 11 B) 12 C) Undefined D) 10
Answer: C
What does
%urepresent inprintf()?
A) unsigned int B) universal value C) unique char D) uninitialized variable
Answer: AWhich header file contains
memcpy()?
A) stdlib.h B) string.h C) stdio.h D) memory.h
Answer: BWhich operator is used to perform bitwise AND?
A) & B) && C) | D) ^
Answer: AWhich keyword is used to define a constant value?
A) const B) define C) #define D) fixed
Answer: CWhat will this print?
char c='A';
printf("%d", c);
A) A B) 65 C) ‘A’ D) Error
Answer: B
Which data type can hold both integer and decimal values?
A) int B) float C) char D) void
Answer: BWhat does the expression
(a = b)do?
A) Compares a and b B) Assigns b to a C) Adds them D) Returns 0
Answer: BWhich function is used to read one character from file?
A) getc() B) fgets() C) getchar() D) scanf()
Answer: AWhich library must be included for
sqrt()?
A) math.h B) stdlib.h C) string.h D) stdio.h
Answer: AWhich escape sequence represents a new line?
A) \t B) \r C) \n D) \
Answer: CWhat is the output of
int i=5;
printf("%d", i>>1);
A) 2 B) 2.5 C) 10 D) 1
Answer: A
Which of these is not a valid loop in C?
A) for B) do-while C) repeat-until D) while
Answer: CWhat is the return type of
main()in standard C?
A) void B) int C) char D) none
Answer: BWhich function is used to clear output buffer?
A) fflush(stdout); B) clear(); C) reset(); D) flush();
Answer: AWhat is the output of
int a=3;
printf("%d", a>2?++a:--a);
A) 2 B) 3 C) 4 D) 5
Answer: C
What is the meaning of
NULLin C?
A) Empty string B) Zero pointer C) 0 value D) None
Answer: BWhat is the default return type of a C function if not specified?
A) int B) void C) float D) char
Answer: AWhat is the output of
int a=10;
printf("%d", a+=a*=2);
A) 30 B) 40 C) 10 D) Undefined
Answer: A
Which of these converts string to integer?
A) atoi() B) atof() C) atol() D) strint()
Answer: AWhich function is used to print error messages?
A) perror() B) ferror() C) print_err() D) stderr()
Answer: AWhat does the
sizeofoperator return?
A) Memory size in bits B) Memory size in bytes C) Value count D) None
Answer: BWhich is the correct syntax to declare pointer to pointer?
A) int **p; B) int p; C) *int *p; D) pointer int p;
Answer: AWhat is the output of
char *p="C";
printf("%c", *p);
A) C B) *p C) p D) Error
Answer: A
Which keyword defines a macro?
A) const B) #define C) define D) static
Answer: BWhich function is used to compare two strings?
A) strcmp() B) strcomp() C) strmatch() D) strdiff()
Answer: AWhat will be printed by
int i=0;
while(i++<3) printf("%d",i);
A) 1 2 3 B) 1 2 3 4 C) 123 D) 0123
Answer: C
Thank you so much!!