- Which of the following is a valid variable name in C?
- A) 1variable
- B) variable_1
- C) variable-1
- D) variable 1
- What is the output of the following code?
printf("%d", 5 + 2 * 3);
- Which data type does not allow decimal points?
- A) float
- B) double
- C) int
- D) char
- What is the use of the
break statement in C?
- A) To terminate a loop
- B) To skip to the next iteration
- C) To exit a function
- D) To pause execution
- Which operator is used to access the value of a variable using a pointer?
- What is the correct syntax to include a header file in C?
- A) import <stdio.h>
- B) include <stdio.h>
- C) #include <stdio.h>
- D) #import <stdio.h>
- What will be the size of an integer variable on a 32-bit system?
- A) 2 bytes
- B) 4 bytes
- C) 8 bytes
- D) Depend on the compiler
- Which loop is guaranteed to execute at least once?
- A) for loop
- B) while loop
- C) do-while loop
- D) none of the above
- Which of the following is a correct way to declare a pointer?
- A) int *ptr;
- B) pointer int ptr;
- C) int &ptr;
- D) int ptr*;
- What will the following code output?
for(int i = 0; i < 5; i++) {
printf("%d ", i);
}
- A) 1 2 3 4 5
- B) 0 1 2 3 4
- C) 0 1 2 3 4 5
- D) 1 2 3 4
- What does
NULL represent in C?
- A) A pointer to a variable
- B) A null character
- C) A pointer that does not point to any valid memory
- D) An uninitialized variable
- Which of the following is not a valid control structure in C?
- A) if-else
- B) switch
- C) select
- D) for
- What is the purpose of the
sizeof operator?
- A) To determine the size of a variable
- B) To allocate memory dynamically
- C) To initialize variables
- D) To convert data types
- Which of the following function prototypes is correct?
- A) void function(int);
- B) void function(int);
- C) int function(void);
- D) All of the above
- Which of these is the correct method to declare an array of integers?
- A) int array[];
- B) int array[10];
- C) int array(10);
- D) array int[10];
- What is the output of the following code?
int x = 5;
printf("%d", x++);
- Which of the following is a valid way to comment in C?
- A) // comment
- B) /* comment */
- C) # comment
- D) Both A and B
- How do you declare a constant in C?
- A) constant int x = 10;
- B) const int x = 10;
- C) #define x 10
- D) Both B and C
- What is the result of the expression
5 & 3?
- Which operator is used for logical AND in C?
- What will the output be of the following code?
printf("%c", 'A' + 1);
- Which library function is used to find the length of a string in C?
- A) strlength()
- B) strlen()
- C) length()
- D) size()
- Which of the following is a standard input/output library in C?
- A) stdlib.h
- B) conio.h
- C) stdio.h
- D) string.h
- What will be the result of
printf("%d", 10/3);?
- A) 3
- B) 3.33
- C) 3.0
- D) 10
- In C, how do you declare a function that takes no parameters?
- A) void function();
- B) void function(void);
- C) Both A and B
- D) None of the above
- What is the default return type of a function in C?
- A) void
- B) int
- C) float
- D) char
- What is the output of the following code?
int a = 5;
int b = 10;
printf("%d", a > b ? a : b);
- How are strings represented in C?
- A) Char arrays
- B) Int arrays
- C) Float arrays
- D) Pointer to char
- What will
sizeof(char) return?
- Which directive is used to define macros in C?
- A) #macro
- B) #define
- C) #constants
- D) #include
- What is the purpose of the
return statement in a function?
- A) To stop the function execution
- B) To return a value to the caller
- C) Both A and B
- D) To call another function
- Which of the following is used to read formatted input from the standard input in C?
- A) printf()
- B) scanf()
- C) gets()
- D) fgetc()
- What will the result of
5 % 2 be?
- What does the following code do?
int x = 1;
x = x << 2;
- A) Shifts x left by 2 bits
- B) Shifts x right by 2 bits
- C) Multiplies x by 4
- D) Both A and C
- How do you declare a multidimensional array?
- A) int array[][];
- B) int array[10][10];
- C) array int[10][10];
- D) int array[10,10];
- What will the following code output?
int a = 5, b = 10;
printf("%d", a & b);
- Which of the following is not a looping statement?
- A) for
- B) while
- C) do-while
- D) switch
- In C, what is the value of
sizeof(int) on a 64-bit system?
- Which function is used to convert a string to an integer in C?
- A) atoi()
- B) itoa()
- C) strtoint()
- D) inttos()
- What is the purpose of
#include <stdlib.h>?
- A) To use input/output functions
- B) To perform memory allocation
- C) To use string manipulation functions
- D) To perform mathematical computations
- How do you access the last element of an array named
arr?
- A) arr[length(arr) – 1]
- B) arr[length – 1]
- C) arr[size – 1]
- D) arr[size(arr) – 1]
- What operator is used for incrementing a variable by one?
- What is the purpose of the
#define directive?
- A) To define a function
- B) To create macros
- C) To allocate memory
- D) To include files
- Which of the following functions can be used to free dynamically allocated memory?
- A) free()
- B) delete()
- C) realloc()
- D) malloc()
- In C, which of the following can be a valid return value for a function declared as
void?
- A) return 0;
- B) return 1;
- C) return NULL;
- D) None of the above
- Which C standard library function is used to compare two strings?
- A) stringcmp()
- B) strcmp()
- C) strcompare()
- D) strcomp()
- What is the output of the following expression?
printf("%d", (1 + 2) * (3 + 4));
- In an array declaration, what does the number in brackets represent?
- A) The maximum size of the array
- B) The minimum size of the array
- C) The initial value of the array
- D) A reserved space in memory
- Which of the following is true about a null pointer?
- A) It stores a valid memory address.
- B) It can be dereferenced.
- C) It points to undefined memory.
- D) It is an address that points to nothing.
- In the context of C programming, what does
printf stand for?
- A) Print format
- B) Print file
- C) Print function
- D) Print format variable