Home
Categories
Technology
Health
Education
Business
Lifestyle
News
Food & Reicipe
Entertainment
Travels and Tourism
Notes
Mock Test
Tools
Submit Study Materials
Pricing
About
Contact
Register
Login
Unit 4: Programming in C (12 Hours)
1. What is the size of an int in C?
2 bytes
4 bytes
8 bytes
Depends on compiler
2. Which of the following is a valid variable name in C?
1stName
first_name
first-name
first.name
3. What is the output of printf("%d", 5 + 10);?
15
510
5 + 10
None of the above
4. Which of the following is the correct way to declare a pointer?
int* ptr;
int ptr*;
ptr int*;
*int ptr;
5. What is the purpose of the main() function in C?
Start of program
End of program
A user-defined function
None of the above
6. Which operator is used to access a member of a structure?
.
->
*
&
7. How do you create a comment in C?
// comment
/* comment */
Both A and B
None of the above
8. What is the result of 3 % 2 in C?
0
1
1.5
2
9. Which data type can hold a decimal value?
int
char
float
all of the above
10. What will be the output of printf("%c", 'A' + 1);?
A
B
C
Error
11. Which of the following is a looping statement in C?
for
if
switch
goto
12. What does the sizeof operator do?
Returns the size of a variable
Returns the number of elements
Returns memory address
None of the above
13. What is the output of the following code? printf("%d", 5 < 10);
0
1
5
10
14. What is the correct way to declare an array in C?
int arr[];
arr int[];
int[] arr;
int arr();
15. Which of the following functions is used to read a string?
scanf
gets
fgets
All of the above
16. What is the purpose of the return statement in C?
To return a value from a function
To exit the program
To declare a function
None of the above
17. Which header file is needed for using printf and scanf?
<stdio.h>
<stdlib.h>
<conio.h>
<string.h>
18. How do you declare a function in C?
void function();
function void();
void function;
function void
19. What is the output of printf("%d", 3 * 2 + 1);?
7
8
6
5
20. What is a NULL pointer?
A pointer with no address
A pointer with an address
A pointer that points to zero
A pointer to a function
21. Which of the following is not a keyword in C?
for
while
repeat
if
22. What is the correct syntax for an if statement in C?
if x > 0 {
if (x > 0)
if x > 0
if [x > 0]
23. Which operator is used to allocate memory dynamically?
new
malloc
alloc
memory
24. What does the break statement do?
Ends the program
Exits a loop
Exits a function
None of the above
25. Which of the following statements is used to terminate a loop?
exit
break
continue
stop
26. What will be the output of printf("%d", 5 == 5);?
0
1
5
Error
27. What is the use of the & operator?
To declare a variable
To get the address of a variable
To assign a value
To perform bitwise AND
28. What will happen if you try to access an array element out of bounds?
Undefined behavior
Compiler error
Accessing memory
None of the above
29. What is the output of printf("%d", 3 + 2 * 2);?
7
10
8
9
30. Which of the following is a logical operator in C?
&&
&
nan
nan
31. How do you include a standard library in C?
#include <library>
include <library>
#include library
#library <library>
32. What will be the output of printf("%d", (5 + 10) / 3);?
5
15
3
4
33. Which of the following data types can store the largest value?
int
long
short
char
34. How can you declare a constant variable in C?
const int x;
int const x;
#define x;
All of the above
35. What is the output of printf("%f", 5.0 / 2);?
2
2.5
2
2.5
36. Which function is used to find the length of a string?
strlen
size
length
strlength
37. How can you create a multi-dimensional array?
int arr[3][4];
arr int[3][4];
int arr[][4][3];
int[3][4] arr;
38. What is the output of printf("%d", sizeof(char));?
1
2
4
8
39. What is the keyword used for defining a macro in C?
macro
def
define
const
40. Which of the following will declare a structure in C?
struct name {}
struct name;
struct name[];
None of the above
41. What is the output of printf("%c", 65);?
A
65
Error
nan
42. How do you declare a function pointer in C?
int (*ptr)();
int ptr();
(*int ptr)();
int *ptr();
43. What is the output of the following code? printf("%d", 5 / 2);
2
2.5
2
Error
44. What does malloc return if memory allocation fails?
nan
0
-1
nan
45. What is the default return type of a function in C?
void
int
char
nan
46. Which of the following is an invalid C declaration?
int x;
float y;
char z;
int;
47. What will be the output of the following code? printf("%d", sizeof(int));
2
4
8
nan
48. How do you access a member of a union?
.
->
*
Both A and B
49. Which of the following is not a valid C statement?
x = 5;
5 = x;
x += 10;
x++;
50. What is the output of printf("%d", 10 / 4);
2
2.5
2
2.5
51. What is the correct way to write an else statement?
else {
else:
else() {
else
52. What will happen if you divide an integer by zero in C?
Runtime error
Undefined behavior
Zero value
nan
53. How can you declare a character array in C?
char arr[];
char arr[10];
Both A and B
None of the above
54. What is the output of the following code? printf("%d", 0);
0
1
nan
Error
55. Which of the following correctly declares a string in C?
char str[] = "Hello";
string str = "Hello";
char str = "Hello";
char[] str = "Hello";
56. What is the size of a float in C?
2 bytes
4 bytes
8 bytes
Depends on compiler
57. What is the result of 3 & 1 in C?
0
1
2
3
58. Which of the following functions can be used to terminate a string?
strlen
strncat
strcat
nan
59. Which of the following is used to declare a structure variable?
struct var;
struct var{};
struct var[];
struct var();
60. What is the output of printf("%d", 10 == 10);
0
1
10
Error
61. How do you define a constant value in C?
const int x = 10;
int const x = 10;
#define x 10;
All of the above
62. What will be the output of printf("%d", 10 / 3);
3
3.33
3
3.3
63. What is a function prototype?
A declaration of a function
A function definition
A function call
nan
64. Which operator is used to perform bitwise OR in C?
nan
nan
nan
nan
65. What will be the output of the following code? printf("%d", 5 - 2);
2
3
5
7
66. What is the result of 5 >> 1 in C?
2
3
4
5
67. What is the correct syntax for declaring a structure?
struct name {};
struct name { }
struct { name };
Both A and B
68. Which of the following correctly defines a macro?
#define PI 3.14
#PI 3.14
define PI 3.14
#define PI = 3.14
69. What will be the output of printf("%d", sizeof(double));
4
8
16
Depends on compiler
70. How can you declare a variable in C that can hold 10 integers?
int arr[10];
int arr();
int[10] arr;
int arr(10);
71. What does fgets do in C?
Reads a string
Writes a string
Displays a string
nan
72. What is the output of printf("%d", 5 + 5);
10
5
15
nan
73. Which of the following is not a loop in C?
for
while
repeat
do-while
74. What is a syntax error?
An error in logic
An error in syntax
An error in memory
nan
75. What does the continue statement do?
Ends the program
Skips the current iteration
Exits the loop
nan
76. What is the output of printf("%d", 3 * (2 + 1));
6
7
9
10
77. How do you define a function that takes two integer arguments?
void function(int a, int b);
void function(a, b);
function int(a, b);
int function(int a, int b);
Check Score
Results