Problem Solving Through Programming In C Week 6
Session: JAN-APR 2023
Course Name: Problem Solving Through Programming In C
Course Link: Click Here
These are Problem Solving Through Programming In C Assignment 6 Answers
Q1. Which statement is correct?
a) An index or subscript in array is a positive integer
b) An index or subscript in array is a positive or negative integer
c) An index or subscript in array is a real number
d) None of the above
Answer: a) An index or subscript in array is a positive integer
Q2. Which of the following is the correct way to declare a one-dimensional integer array named “myArray” with 5 elements in C?
a) int myArray(5);
b) int myArray[5];
c) int myArray = [5];
d) int myArray = {5};
Answer: b) int myArray[5];
These are Problem Solving Through Programming In C Assignment 6 Answers
Q3. The elements of array are stored in contiguous memory due to
a) This way computers can keep track of only the address of the first element and the addresses of other elements can be calculated.
b) The architecture of computer does not allow arrays to store other than serially
c) Both (a) and (b) are true
d) None of these are true
Answer: a) This way computers can keep track of only the address of the first element and the addresses of other elements can be calculated.
Q4.

a) 0
b) 1
c) 5
d) The code will result in a runtime error.
Answer: a) 0
These are Problem Solving Through Programming In C Assignment 6 Answers
Q5.

Answer: 150
Q6. What is the maximum dimension of an array allowed in C?
a) 10
b) 100
c) 1000
d) No such limit exists
Answer: d) No such limit exists
These are Problem Solving Through Programming In C Assignment 6 Answers
Q7.

a) 1 followed by two garbage values
b) 1 1 1
c) 1 0 0
d) 0 0 0
Answer: c) 1 0 0
Q8. A one-dimensional array X has indices 1….50. Each element is an int. The array is stored at location 1000 decimal. The starting address of X[27] is ______(assume int takes 4 bytes).
Answer: 1104
These are Problem Solving Through Programming In C Assignment 6 Answers
Q9. Which of the following statements finds the minimum value in an integer array named “myArray” in C?




Answer: c)
Q10. What will be the output?
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: a) i=5, j=5, k=2
These are Problem Solving Through Programming In C Assignment 6 Answers
Problem Solving Through Programming In C Programming Assignment
Question 1
Write a C Program to find Largest Element of an Integer Array.
Here the number of elements in the array ‘n’ and the elements of the array is read from the test data.
Use the printf statement given below to print the largest element.
printf(“Largest element = %d”, largest);
Solution:
largest = arr[0];
for(i = 1; i< n; ++i)
{
if(largest <arr[i])
largest = arr[i];
}
printf("Largest element = %d", largest);
return 0;
}
Question 2
Write a C Program to print the array elements in reverse order (Not reverse sorted order. Just the last element will become first element, second last element will become second element and so on)
Here the size of the array, ‘n’ and the array elements is accepted from the test case data.
The last part i.e. printing the array is also written.
You have to complete the program so that it prints in the reverse order.
Solution:
int j, temp;
j = i - 1;
i = 0;
while (i<j)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j--;
}
These are Problem Solving Through Programming In C Assignment 6 Answers
Question 3
Write a C program to read Two One Dimensional Arrays of same data type (integer type) and merge them into another One Dimensional Array of same type.
Solution:
int j;
for (i=0;i<n1;++i)
array_new[i]=arr1[i];
size = n1 + n2;
for(i=0, j=n1; j<size && i<n2; ++i, ++j)
array_new[j] = arr2[i];
Question 4
C Program to delete an element from a specified location of an Array starting from array[0] as the 1st position, array[1] as second position and so on.
Solution:
for (i = pos - 1; i < num - 1; i++)
{
array[i] = array[i+1];
}
num--;
These are Problem Solving Through Programming In C Assignment 6 Answers
More Weeks of Problem Solving Through Programming In C: Click Here
More Nptel courses: https://progiez.com/nptel
Session: JULY-DEC 2022
Course Name: Problem Solving Through Programming In C NPTEL
Link of course: Click Here
These are Problem Solving Through Programming In C Assignment 6 Answers
Q1. What is the right way to initialise an array in C?
a) int ar{}= {1,2, 5,6,9}
b) int ar[5]= {1,2, 5,6,9}
c) int ar {5} = {1,2, 5,6,9}
d) int ar()= {1,2, 5,6,9}
Answer: b
Q2. An integer array of dimension 10 is declared in a C program. The memory location of the first byte of the array is 1000. What will be the location of the 9th element of the array? (Assume integer takes 4 bytes of memory and the element stored at 1000 is identified as 1st element)
a) 1028
b) 1032
c) 1024
d) 1036
Answer: b
Q3. What will be the output after execution of the program?
Answer: a
These are Problem Solving Through Programming In C Assignment 6 Answers
Q4. Which of the statements is/are correct?
a) An array may contain more than one element
b) All elements of array have to be of same data type
c) The size of array has to be declared upfront
d) All of the above
Answer: d
Q5. What actually gets passed when you pass an array as an argument to a function
a) Value of elements in array
b) First element of the array
c) Base address of the array
d) Address of the last element of array
Answer: c
Q6. Find the output of the following C program
Answer: c
These are Problem Solving Through Programming In C Assignment 6 Answers
Q7. What will be the output?
Answer: c
Q8. An array of the void data type
a) can store any data-type
b) only stores element of similar data type to first element
c) acquires the data type with the highest precision in it
d) It is not possible have an array of void data type
Answer: d
Q9. What will be the output?
Answer: 20
These are Problem Solving Through Programming In C Assignment 6 Answers
Q10. How many ‘a’ will be printed when the following code is executed?
Answer: 6
Programming Assignment Answers
These are Problem Solving Through Programming In C Assignment 6 Answers
Question 1
Write a C Program to find Largest Element of an Integer Array.
Here the number of elements in the array ‘n’ and the elements of the array is read from the test data.
Use the printf statement given below to print the largest element.
printf(“Largest element = %d”, largest);
Solution:
//Code
These are Problem Solving Through Programming In C Assignment 6 Answers
Question 2
Write a C Program to print the array elements in reverse order (Not reverse sorted order. Just the last element will become first element, second last element will become second element and so on) Here the size of the array, ‘n’ and the array elements is accepted from the test case data. The last part i.e. printing the array is also written.
You have to complete the program so that it prints in the reverse order.
Solution:
//Code
These are Problem Solving Through Programming In C Assignment 6 Answers
Question 3
Write a C program to read Two One Dimensional Arrays of same data type (integer type) and merge them into another One Dimensional Array of same type.
Solution:
//Code
These are Problem Solving Through Programming In C Assignment 6 Answers
Question 4
Write a C Program to delete duplicate elements from an array of integers.
Solution:
//Code
These are Problem Solving Through Programming In C Assignment 6 Answers
More NPTEL Solution: https://progiez.com/nptel
* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first. COPYING MATERIALS IS STRICTLY PROHIBITED.
More from PROGIEZ
