NPTEL Problem Solving Through Programming In C Week 6 Assignment Answers 2024

NPTEL Problem Solving Through Programming In C Week 6 Assignment Answers 2024

1. What does the expression sizeof(arr) / sizeof(arr[0]) evaluate to, where arr is an integer array of 100 elements?

a) 100
b) 400
c) 25
d) 4

`Answer :- For Answer Click Here `

2. Considering a two-dimensional array declared as int arr[3][4];, what is the correct way to access the second element of the third row?

a) arr[3][2]
b) arr[2][1]
c) arr[2][3]
d) arr[1][2]

`Answer :-  For Answer Click Here `

3. How does a C program react when an attempt is made to access an array element using a floating-point index, such as arr[1.5]?

a) The element corresponding to the floor of the index is accessed.
b) The element corresponding to the ceiling of the index is accessed.
c) A syntax error is reported by the compiler.
d) The program executes successfully without errors.

`Answer :-  For Answer Click Here `

4. In a C program, what is the outcome of declaring an array with a negative size, such as int arr[-10];?

a) The compiler will treat it as a positive size.
b) The array will be initialized with zero elements.
c) The compiler will generate an error.
d) A memory allocation error will occur at runtime.

`Answer :- `

5. An integer array of size 15 is declared in a C program. The memory location of the first byte of the array is 2000. What will be the location of the 13th element of the array? (Assuming that an integer takes 2 bytes)

a) 2013
b) 2024
c) 2026
d) 2030

`Answer :- `

6. The elements of an array are stored in contiguous memory due to

a) This way, the computer can keep track of only the address of the first element, and the addresses of other elements can be calculated.
b) The architecture of the computer does not allow arrays to store other than serially
c) Both
d) None

`Answer :-  For Answer Click Here `

7. What is the effect of executing the statement int arr[5] = {1, 2}; in C?

a) The first two elements are set to 1 and 2, rest are uninitialized.
b) The first two elements are set to 1 and 2, rest are set to 0.
c) All elements are set to 1 and 2 alternatively.
d) The compiler generates an error.

`Answer :- `

8. How can you pass an entire array to a function in C?

a) By specifying the size of the array in the function parameter.
b) By passing the value of the first element of the array.
c) By declaring the function parameter as an array size.
d) By passing the array name only.

`Answer :- `

9.

a) 5,4
b) 5,5
c) 4,4
d) 3,4

`Answer :- `

10.

a) i=5, j=5, k=2
b) i=6, j=5, k=3
c) i=6, j=4, k=2
d) i=5, j=4, k=2

`Answer :-  For Answer Click Here `