0% found this document useful (0 votes)
2 views

Midterm Answer

Uploaded by

jo718695
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Midterm Answer

Uploaded by

jo718695
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Midterm Exam Course Name:

Date : 17/11/ 2025 Course Code :


Time : 1 Hour Level : second
No. of Page : pages Program :
No. of Questions : 20 Term No. : first
Zagazig National University
Full Mark : 15 The Engineering Sector

 Choose the correct answer


1. Which of the following statements is true about arrays in C?

A) The size of an array can be changed at B) Array elements are stored in contiguous
runtime. memory locations.

C) Array indexing starts from 1. D) Array can store different data types.

2. What is the output of the following code?


int arr[5] = {10, 20, 30, 40, 50};
printf("%d", arr[5]);
A) 10 . B) 50 .

C) Garbage value or runtime error . D) 0 .

3. If an array int arr[5]; is partially initialized as int arr[5] = {10, 20};, what will be the value of
arr[3]?
A) 10 . B) 20 .

C) 0 . D) Garbage value.

4. Which of the following correctly declares an array of 10 integers in C?

A) int arr[10]; B) int arr(10);

C) arr int[10]; D) array int arr[10];

5. Which function adds a string to the end of another string?

A) stradd( ) . B) strcat( ) .

C) strtok( ) . D) strcpy( ) .

6. What is the value of strlen("Hello") in C?


A) 5 . B) 6 .

1
C) 4 . D) 0 .

7. A structure member variable is generally accessed using

A) Address operator . B) Dot operator .


.

C) Comma operator . D)Ternary operator.

8. Memory for a structure is allocated at the time of

A) Structure definition. B) Structure variable declaration .

C) Structure declaration. D)Function declaration.

9. A data structure that can store related information of different data types together is called

A) Array . B) String .

C) Structure . D) All of these .

10. What is the keyword used to define a structure in C?

A) struct . B) structure .

C) union . D) enum .

11. Which operator is used to access members of a structure through a pointer?

A) . B) &

C) -> D) *

12. Which of the following is a correct way to define and initialize a structure in C?
struct Point {
int x;
int y;
};
A) struct Point p = {x: 10, y: 20}; B) struct Point p = {10, 20};

2
C) Point p = {10, 20}; D) Point p{10, 20};

13. How can you define an array of structures in C?


struct Book {
char title[50];
int pages;
};
A) struct Book books[5]; B) struct books[5];

C) Book[5] books; D) struct Book books;

14. What is the primary purpose of using a typedef with structures?


A) To allocate more memory for structures. B) To allow structure members to access
each other directly.

C) To give a custom name to the structure D) To ensure the structure has public access.
for easier use.

15. What will happen if you try to access the next pointer of the last node in a singly linked list?
A) It will point to the first node in the list B) It will contain a garbage value

C) It will point to itself D) It will be NULL

16. Which operation is typically the slowest in a singly linked list?


A) Insertion at the beginning B) Deletion at the beginning

C) Traversing the list to find an element D) Deleting the first node

17. What happens when a node is inserted at the beginning of a singly linked list?
A) The new node becomes the last node in B) The new node becomes the first node, and
the list. its next pointer points to the previous first
node.

C) The new node points to the second node. D) The new node points to NULL.

3
18. What is the main advantage of using a linked list over an array?
A) Faster random access . B) Dynamic memory allocation .

C) Lower memory overhead . D) Direct access to the middle element .

19. In the case of a singly linked list, which pointer typically marks the end of the list?
A) The head pointer . B) The last pointer .

C) The next pointer of the last node, which D) The next pointer of the first node, which
points to NULL . points to NULL .

20. How is memory allocated for a linked list in C?

A) Memory for a linked list is allocated in B) Memory for each node is allocated
contiguous blocks. dynamically using malloc or calloc.

C) Memory for linked lists is allocated D) Memory is allocated only for the first
statically. node in the list.

You might also like