23UCAFC11 - Unit II
23UCAFC11 - Unit II
Sl.No Unit
1 I
2 I
3 I
4 I
5 I
6 I
7 I
8 I
9 I
10 I
11 I
12 I
13 I
14 I
15 I
16 I
17 I
18 I
19 I
20 I
21 I
22 I
23 I
24 I
25 I
26 I
27 I
28 I
29 I
30 I
31 I
32 I
33 I
34 I
35 I
36 I
37 I
38 I
39 I
40 I
41 I
42 I
43 I
44 I
45 I
46 I
47 I
48 I
49 I
50 I
51 I
52 I
53 I
54 I
55 I
56 I
57 I
58 I
59 I
60 I
Mannar Thirumalai Naicker College
Question
Option A
Web development
High-level abstractions
Slowness in execution
Healthcare
Java Compiler
Low-level
Word processing
Complex
struct : MyStruct
constant
<stdio.h>
main()
int x = 10;
exit
To declare variables
new
.src
/* This is a comment */
A value that can be changed during program
execution
my_variable
int
32767
var
int
2 bytes
\n
ASCII
my_variable
Period (.)
8 characters
integer
A keyword used to define data types
break
15
To declare a variable.
x is 8.
Performs subtraction.
float
Yes
16
&&
++
TRUE
<<
Bitwise operations
x is 2.
Function
1970
Option B
Game development
Ease of learning
Limited libraries
Automotive
Python Compiler
High-level
Lack of pointers
Spreadsheet
Computer
structure MyStruct
immutable
<iostream.h>
execute()
x = 10;
quit
To define functions
alloc
.csrc
// This is a comment
123_variable
char
65535
define
float
4 bytes
\t
Unicode
_variable
Semicolon (;)
16 characters
real
A sequence of characters representing a single element in
the program
main
12
const r = 10;
x is 5
==
Performs division
double
No
11
3.333
||
--
0
>>
Assignment
x is 5
Assignment
1971
Option C
System programming
Portability
Fashion
Middle-level
Database management
Creative
struct MyStruct
const
<stdlib.h>
start()
x := 10;
continue
To perform conditional execution
malloc
.code
-- This is a comment
_variable123
float
2147483647
const
double
8 bytes
It is undefined
\r
EBCDIC
123variable
Colon (:)
32 characters
If
An identifier used for loop control
while
45
x is 15.
:=
const
12
3.4
&
+=
1
&
Conditional expressions
x is 15.
Array
1980
Option D
Visual interface
Complexity in syntax
Agriculture
PHP Compiler
Visual
Power point
Compiled
declare MyStruct
Read only
<conio.h>
run()
set x = 10;
break
To iterate through a loop
allocate
.c
variable123
double
4294967295
constant
char
&
-1
\t
ISO-8859-1
variable123
float
A reserved word for function declaration
case
33
To perform addition
x is 3
!=
Performs multiplication
float const
10
&
/=
0
&&
14
Logical OR
x is 3
Structure
1981
Correct option
c
System programming
c
Portability
c
Speed and efficiency
b
Automotive
c
GCC (GNU Compiler Collection)
c
Middle-level
d
It helps in managing hardware resources efficiently.
D
Limited control structures
C
Database management
B
Computer
C
struct MyStruct
C
const
a
<stdio.h>
A
main()
a
int x = 10;
D
break
C
To perform conditional execution
C
malloc
D
.c
B
// This is a comment
B
A value that cannot be changed during program execution
B
123_variable
B
char
D
4.29E+09
C
const
C
double
B
4 bytes
A
%
C
It is undefined
A
\n
A
ASCII
C
123variable
B
Semicolon (;)
D
There is no maximum length.
C
If
B
A sequence of characters representing a single element in the program
B
main
A
15
C
To exit a function and return a value
B
To store values that cannot be modified after initialization
A
const int r = 10;
C
To assign a value to a variable
A
x is 8.
B
==
C
Performs addition with assignment.
D
float const
B
No
a
const int numbers[5] = {1, 2, 3, 4, 5};
B
11
B
%
A
3
A
&&
A
++
A
TRUE
B
>>
B
4
C
Conditional expressions
A
x is 2.
A
Function
A
1970
Mannar Thirumalai Naicker Col
Subject code: 23UCAFC11
Sl.No Unit
1 II
2 II
3 II
4 II
5 II
6 II
7 II
8 II
9 II
10 II
11 II
12 II
13 II
14 II
15 II
16 II
17 II
18 II
19 II
20 II
21 II
22 II
23 II
24 II
25 II
26 II
27 II
28 II
29 II
30 II
31 II
32 II
33 II
34 II
35 II
36 II
37 II
38 II
39 II
40 II
41 II
42 II
43 II
44 II
45 II
46 II
47 II
48 II
49 II
50 II
51 II
52 II
53 II
54 II
55 II
56 II
57 II
58 II
59 II
60 II
Mannar Thirumalai Naicker College
Subject code: 23UCAFC11
Question
Option A
To define a function
==
TRUE
int
&&
It is skipped
To declare variables
==
&&
if-else statement
for
It represents a loop control
statement
if (condition) { /* code */ } else
{ /* code */ }
It indicates the end of the
program.
continue
int
It specifies the final case in the
switch statement
To declare variables
for
Zero times
TRUE
Use the "break" statement
Zero times
It is guaranteed to execute at
least once
To exit the loop prematurely
+-
It separates the loop condition
from the loop body
A loop that runs exactly once
To declare variables
while
Only one
one
Initialization
To specify the loop's exit condition
exit
Option B
To declare a variable
FALSE
The program executes the code block
inside the `if` statement
float
||
To define a function
||
while
float
It is used to catch any cases that don't
match the other case labels.
To define functions
do
One time
0
Use the "continue" statement
To skip the rest of the code in the loop
and move to the next iteration
Variables are automatically initialized to
0
The loop doesn't run at all
To repeat a block of code while a
condition is true
After executing the loop's body
Once
It is never executed if the condition is
false initially
To restart the loop from the beginning
=
It is a syntax error; a semicolon should
not be there.
A loop that never terminates
To define functions
do
Two
two
Condition
To declare loop control variables
break
To skip the current iteration and
proceed to the next one
By setting the loop condition to "true"
Option C
!=
Error
Error
The program skips the code block inside the
`if` statement
char
!
To specify an alternative code block to
execute when the `if` condition is false
It causes an error.
!=
It specifies an alternative action if the "if"
condition is false
It can only have one condition
To provide an alternative condition to check if
the initial if condition is false.
!
By using the "switch" keyword followed by
multiple "case" labels
Execution continues to the next case without
any checks
It is used to create a loop
while loop
if
It is used to specify an alternative action
when the "if" condition is false.
if (condition) then { /* code */ } else { /* code
*/ }
It is used to exit the switch statement and
continue with the code after the switch
goto
double
Indefinitely
0
Remove the condition
Infinite times
for
Three
three
Increment
To initialize loop control variables
continue
To create a loop C
To perform decision making and branching
> A
==
8A
TRUE
8B
FALSE
The program prints an error
message
C
The program skips the code block inside the `if` state
string D
string
% A
&&
To print a message C
To specify an alternative code block to execute whe
<> C
!=
% A
&&
for loop C
while loop
do-while C
if
It is used to create a switch
case
C
It is used to specify an alternative action when the "
if (condition) [ /* code */ ] else
[ /* code */ ]
A
if (condition) { /* code */ } else { /* code */ }
break C
goto
It is used to switch between
different cases in a switch B
It is used to jump to a labeled statement within the
statement
Jumping to a label in the same
switch statement.
C
Jumping to a label in a different function
Use functions and modular
programming
D
Use functions and modular programming
char A
int
loop C
while
1A
TRUE
You cannot exit a while loop
prematurely
A
Use the "break" statement
-- C
++
if C
for
As many as needed D
As many as needed
four
C
three
return B
break
To print a message to the
console
B
To skip the current iteration and proceed to the nex
ased on conditions
de */ } else { /* code */ }
switch statement and continue with the code after the switch
a different function
odular programming
le (condition);
f code repeatedly
trol variables
ondition to "true"
Mannar Thirumalai Naic
Subject code: 23UCAFC11
Sl.No Unit
1. III
2. III
3. III
4. III
5. III
6. III
7. III
8. III
9. III
10. III
11. III
12. III
13. III
14. III
15. III
16. III
17. III
18. III
19. III
20. III
21. III
22. III
23. III
24. III
25. III
26. III
27. III
28. III
29. III
30. III
31. III
32. III
33. III
34. III
35. III
36. III
37. III
38. III
39. III
40. III
41. III
42. III
43. III
44. III
45. III
46. III
47. III
48. III
49. III
50. III
51. III
52. III
53. III
54. III
55. III
56. III
57. III
58. III
59. III
60. III
Mannar Thirumalai Naicker College
Subject code: 23UCAFC11
Question
What is the correct way to declare an array of integers named "myArray" with 5 eleme
in C?
How do you declare a character array named "name" with a maximum length of 50
characters in C?
. In C, can you change the size of an array after it has been declared?
What is the index of the last element in an array declared as int arr[7] in C?
What happens if you try to access an array element at an index that is out of bounds i
C?
Which of the following is the correct way to access the first element of an array in C?
What happens if you try to access an array element with an index that is out of bound
How do you access the last element of an array in C, assuming the array has 'n'
elements?
In C, can you use a negative index to access elements from the end of an array?
What is the purpose of bounds checking when accessing array elements?
Which C standard library function can be used to safely copy elements from one array
another, ensuring no buffer overflows occur?
In a multi-dimensional array `arr[m][n]`, how do you access an element at row `i` and
column `j`?
What is the correct way to initialize a two-dimensional character array with strings in C
How can you initialize a two-dimensional array with all elements set to zero in C?
How do you initialize a two-dimensional array with different values in each row and
column in C?
What is the correct syntax to initialize a one-dimensional integer array in C with three
elements?
How can you initialize all elements of a one-dimensional array of floats to 0.0 in C?
What happens if you don't specify the size of a one-dimensional array during initializat
in C?
Which of the following is a valid way to initialize a one-dimensional array in C with all
elements set to 1?
____ are derived data types in c
When initializing a multi-dimensional array, what happens if you provide fewer values
than the array can hold?
To access the first element in a one-dimensional array in C, which index should you us
Given a three-dimensional array `cube` with dimensions `2x3x4`, how would you acce
the element at coordinates `(1, 2, 3)`?
Which of the following is the correct way to access an element in a one-dimensional ar
using a pointer in C?
How would you access the last element in a one-dimensional array `arr` of size `n`?
Which of the following sorting algorithms has an average time complexity of O(n log n
and is often considered one of the fastest sorting algorithms?
In C programming, arrays are zero-indexed. What does this mean?
In C programming, how can you access the third element of an integer array `arr`?
Which function is commonly used in C to compare elements when sorting using the
qsort() function from the C Standard Library?
How do you access an element in a 2D array with row index `i` and column index `j`?
What is the index of the last element in a 2D array `arr` with dimensions `M x N`?
``c int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; printf("%d", arr[1][2]); ```
result
How do you iterate through all the elements of a 2D array `arr` with dimensions `M x
using nested loops?
Subject Title: Structured Programming in C
Option A Option B
10 20
Yes No
6 7
. ::
array_name[element_index] element_index[array_name]
0 1
array[0] array[10]
array[n-1] array[n-11]
Yes No
It increases the program's
It prevents buffer overflows
performance
memcpy() strcpy()
arr[I j] arr[ij)
13 14
array(1) array[1]
matrix(2, 3) matrix[2][3]
array[1][2][3] array(1, 2, 3)
0 1
cube(1, 2, 3) . cube[1][2][3]
*array &array
arr[n] arr[n-1]
`arr(2)` `arr[3]`
cmp() compare()
1 2
`sizeof(array) /
`sizeof(array[0])`
sizeof(array[0])`
2 4
void myFunction(int
void myFunction(int matrix[][])`
*matrix[])`
Two `for` loops with `i` from 0 to Two `while` loops with `i`
M and `j` from 0 to N. and `j` as loop counters.
Option C Option D
40 30
1 2
0 1
; []
element_index++
array_name[element_index]++
[array_name]
-1 2
array[20] array[30]
array[n+1] array[n+11]
0 1
It helps in dynamic memory It's not necessary in C
allocation programming
strcat() strncpy()
arr[i][j] Arr(i)[j]
char str[6] = {'H', 'e', 'l', 'l', char str[5] = {'H', 'e', 'l', 'l',
'o'}; 'o'};
15 12
array{1} array|1]
. matrix{2, 3} matrix|2|3|
array{1, 2, 3} array|1|2|3|
-1 2
cube{1, 2, 3} cube|1|2|3|
array* array&
. arr[1] arr[last]
arr[2]` `arr.third`
a custom comparison
strcmp()
function
`int array[] = {rows,
`int array[rows, columns];`
columns};`
`array[0].length` `array.length`
6 8
A
int myArray[5];
A
char name[50];
C
40
B
No
A
int numbers[5] = {1, 2, 3};
A
6
D
[]
A
The program terminates with an error
B
int matrix[3][3];
C
int (*arrayPtr)[];
A
array_name[element_index]
A
0
A
array[0]
D
It can lead to undefined behavior
array[n-1]
A
A
Yes
A
It prevents buffer overflows
A
memcpy()
C
arr[i][j]
B
The address of the first element
A
`int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};`
A
`char words[2][10] = {"Hello", "World"};`
A
int arr[3] = {1, 2, 3};
A
Compile time
c
Dope Vector
b
call by reference
b
14
A
int matrix[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
B
int multi[2][3] = {{1, 2, 3}, {4, 5, 6}};
B
The compiler automatically fills in missing values with zeros.
A
char str[] = "Hello";
B
array[1]
B
matrix[2][3]
A
array[1][2][3]
A
0
B
The row number.
B
. cube[1][2][3]
A
*array
B
arr[n-1]
C
Merge Sort
C
The first element of the array has an index of 0.
C
arr[2]`
D
a custom comparison function
B
`int array[rows][columns];`
B
`array[i][j]`
D
There is no maximum limit
B
`int matrix[2][2] = {{1, 2}, {3, 4}};`
A
`M-1, N-1`
B
Row-major order
B
`sizeof(array) / sizeof(array[0])`
6
C
C
void myFunction(int matrix[][N])`
A
Two `for` loops with `i` from 0 to M and `j` from 0 to N.
element individually
Sl.No Unit
1 IV
2 IV
3 IV
4 IV
5 IV
6 IV
7 IV
8 IV
9 IV
10 IV
11 IV
12 IV
13 IV
14 IV
15 IV
16 IV
17 IV
18 IV
19 IV
20 IV
21 IV
22 IV
23 IV
24 IV
25 IV
26 IV
27 IV
28 IV
29 IV
30 IV
31 IV
32 IV
33 IV
34 IV
35 IV
36 IV
37 IV
38 IV
39 IV
40 IV
41 IV
42 IV
43 IV
44 IV
45 IV
46 IV
47 IV
48 IV
49 IV
50 IV
51 IV
52 IV
53 IV
54 IV
55 IV
56 IV
57 IV
58 IV
59 IV
60 IV
Mannar Thirumalai Naicker College
ct code: 23UCAFC11
Question
In C, which keyword is used to indicate that a function does not return a value?
Which keyword is used to declare a function that does not return any value?
If a function does not have a return statement, what will be the default return
value?
Which keyword is used to indicate the end of a function and return a value in C?
Which of the following is a valid way to declare a function that returns a floating-
point value?
In C, can a function return an array?
What is the process by which a recursive function calls itself with smaller or
simpler inputs?**
In a call by value function, can the function modify the original value of the
argument passed?
When using call by reference, which operator is used to access the value stored at
a memory address?
Which library function is used to input a string from the standard input in C?**
Disadvantage of array in C is
What happens when you try to access an array variable outside its size
Subject Title: Structured Programming in C
A reusable block of
A variable A statement
code
0 1 -1
* & ->
Depends on
0 1 storage class
some garbage value
will be return 1 11
Option D Correct option
A data type C
A reusable block of code
int D
int
strlen() C
myFunction()
It defines the
A
main() function. It defines the function's name and return type.
They remove the
need for a main() A
function. They reduce code redundancy.
print_hello B
123function
double A
int
none C
void
It is never
C
required. For all functions that return a value.
program() A
main()
char B
int
void D
void
Unlimited A
One
string D
string
) It will produce a
A
compilation error 0
exit C
return
char myFunction(); A
float myFunction();
1B
No
User-defined
A
functions Void functions
User-defined
D
functions User-defined functions
User-defined
B
functions Standard functions
User-defined
C
functions Library functions
User-defined
A
functions Preprocessor functions
User-defined
A
functions Preprocessor functions
A function that can
only be called B
recursively A function defined inside another function
A case where the
function returns a C
non-zero The terminating condition that stops recursion
Recursionvalue
can only
be used with C
nested functions Recursion can lead to a stack overflow if not handled
char C
struct
:: A
*
An array of
C
pointers An array of characters
`read()` A
gets()`
'\t' A
\0'
To convert a string
C
to uppercase To find the length of a string
`strcpy()` B
`strcmp()`
It depends on the
D
available memory It depends on the available memory
`strcpy()` D
`strcpy()`
`char[20]
A
myString;` char myString[20];`
`string` B
`char*`
`intToStr()` A
`atoi()`
run time
Error c
Zero b
multi dimensional
four d
four
sorting
Int b
i
i d
int n(6) = { 2, 4,
a
12, 5, 45, 5 }; int num[6]={2,3,12,45,5,6}
multiple a
sequential
Single data a
same data type
null c
Depends on storage class
a
0 some garbage value will be return
eturn type.
s recursion
ctual parameter, while call by reference passes the actual parameter itself.
original value.
ginal data.
Sl.No Unit
1.
V
2.
V
3.
V
4.
V
5 V
6 v
7 V
8 V
9 V
10 V
11 V
12 V
13 V
13 V
14 V
15 V
16 V
17 V
18 V
19 V
20 V
21 V
22 V
23 V
24 V
25 V
26 V
27 V
28 V
29 V
30 V
31 V
32 V
33 V
34 V
35 V
36 V
37 V
38 V
39 V
40 V
41 V
42 V
43 V
44 V
45 V
46 V
47 V
48 V
49 V
50 V
51 V
52 V
53 V
54 V
55 V
56 V
57 V
58 V
59 V
60 v
Mannar Thirumalai Nai
Subject code: 23UCAFC11
Question
Which of the following is used to access the value stored at the address
pointed to by a pointer?
In C, what does the asterisk (*) symbol indicate when used in a variable
declaration?
What does the following code snippet do? char *str = "Hello, World!";
When initializing a pointer to an integer with a specific value, which of the
following is correct?**
What does the `&` operator do in C when used with a variable?**
What does the `sizeof` operator return when used with a pointer?**
What does the `sizeof` operator return when used with a pointer?
What is a pointer in C?
Option A
Multiplication operator
1 byte
To get the value stored at a memory
location
-> operator
`double *ptr;`
It denotes multiplication.
char *str;`
char *str;`
To allocate memory.
commas (,)Using
`int *arr
It is set to zero.
`*`
8 bytes
You can add, subtract, multiply, and divide
pointers directly
The size of the memory address.
int array[];
::
To store characters
Pass it by value
return
&
Logical operations
`ptr.age`
char
To allocate memory
Recursive Function
Subject Title: Structured Programming in C
Option B
Division operator
2 bytes
* operator
) `ptr *int;`
`ptr *double;`
`char str[];`
`char str[];`
To initialize a variable.
`int arr[5]*;`
int *ptr = 0;
Declares a character array and initializes it
with "Hello, World!".
int *ptr = &42;
It performs a logical AND operation on the
variable.
To point to the address 0x0000, indicating it
does not point to any valid memory location.
`int_ptr ptr;`
`->`
4 bytes
&
array<int>;
->
Pass it by reference
void
`int *ptr;`
`ptr->age`
character
Static
ng in C
Option C Option D
A variable that stores the A function that points to other
address of another variable functions
Pointer declaration and
Addition operator
dereferencing
4 bytes 8 bytes
To get the address of a
To perform bitwise AND operation
variable
`.` `&`
-> %
. []
main printf
$ %
chr singlechar
C
A variable that stores the address of another variable
C
Pointer declaration and dereferencing
C
4 bytes
C
To get the address of a variable
* operator
B
D 0
A
To perform arithmetic operations on pointer variables
A
`int *ptr;`
A
`double *ptr;`
char *str;`
A
A
C
To store the address of another variable.
A
commas (,)Using
A
`int *arr
B
It contains a random memory address.
B
int *ptr = &value;
A
int *ptr = NULL;
A
Declares a pointer to a character array and initializes it with "
C
int *ptr = (int *)42;
C
It returns the memory address of the variable.
B
To point to the address 0x0000, indicating it does not point to
D
`int *ptr;`
A
`*`
B
4 bytes
B
You can only add and subtract pointers.
C
The size of the pointer variable itself.
D
To dynamically allocate memory for data storage during progr
C
It returns the memory address of the variable.
B
To point to the address 0x0000, indicating it does not point to
D
`int *ptr;`
B
You can only add and subtract pointers.
C
The size of the pointer variable itself.
A
*
D
int array[10];
C
Allocate memory on the heap
It points to address 0
C
D
[]
C
To point to the memory address of a variable
C
*
C
It accesses a member of a structure through a pointer
B
To allocate memory for a variable at runtime
A
Pass it by value
A return
A &
B `int *ptr;`
B
Accessing members of a structure through a pointer
C
The size of the pointer variable itself
B
To allocate memory for a structure
B
`ptr->age`
A
char
A
To create a new data type alias
C
To release previously allocated memory
a
Recursive Function
other variable
nter variables
and initializes it with "Hello, World!".
riable.
riable.
ough a pointer
gh a pointer