Home

Swayam Solver

Learn Programming & Prepare for NPTEL Exams...

Find your course

Explore Courses

Latest Blog Posts

NPTEL Problem Solving Through Programming In C - Programming Assignment | July-2025

 

NPTEL » Problem Solving through Programming in C


  Please scroll down for latest Programs. ðŸ‘‡ 


Week-06 Program-01

Due on 2025-09-04, 23:59 IST
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);
Select the Language for this assignment. 
1
~~~THERE IS SOME INVISIBLE CODE HERE~~~
2
#include <stdio.h>
3
int main()
4
{
5
    int i, n, largest;
6
    int arr[100];
7
    scanf("%d", &n); /*Accepts total number of elements from the test data */
8
for(i = 0; i < n; ++i)
9
    {
10
       scanf("%d", &arr[i]); /* Accepts the array element from test data */
11
    }
12
largest = arr[0];
13
for(i = 1; i < n; ++i)
14
    {
15
           if(largest < arr[i])
16
           largest = arr[i];
17
    }
18
    printf("Largest element = %d", largest);
19
    return 0;
20
}
You may submit any number of times before the due date. The final submission will be considered for grading.
Assignment will be evaluated only after submitting using Submit button below. If you only save as , your assignment will not be graded and you will not see your score after the deadline.



Week-06 Program-02

Due on 2025-09-04, 23:59 IST
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.
Your last recorded submission was on 2025-08-29, 16:58 IST
Select the Language for this assignment. 
1
#include<stdio.h>
2
 
3
int main() {
4
   int arr[20], i, n;
5
 
6
   scanf("%d", &n); /* Accepts the number of elements in the array */
7
8
  for (i = 0; i < n; i++) 
9
     scanf("%d", &arr[i]); /*Accepts the elements of the array */
10
int j, temp;  
11
j = i - 1;   // last Element of the array
12
i = 0;       // first element of the array
13
   while (i < j) {
14
      temp = arr[i];
15
      arr[i] = arr[j];
16
      arr[j] = temp;
17
      i++;             
18
      j--;        
19
   }
0
for (i = 0; i < n; i++) {
1
      printf("%d\n", arr[i]); // For printing the array elements 
2
   }
3
 
4
   return (0);
5
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
5
1
2
3
4
5
5\n
4\n
3\n
2\n
1
5\n
4\n
3\n
2\n
1\n
Passed after ignoring Presentation Error
Test Case 2
4
45
65
35
25
25\n
35\n
65\n
45
25\n
35\n
65\n
45\n
Passed after ignoring Presentation Error



Week-06 Program-03

Due on 2025-09-04, 23:59 IST
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.
Your last recorded submission was on 2025-08-29, 16:59 IST
Select the Language for this assignment. 
1
#include<stdio.h>
2
int main() 
3
{
4
   int arr1[20], arr2[20], array_new[40], n1, n2, size, i;
5
 /*n1 size of first array (i.e. arr1[]), n2 size of second array(i.e. arr2[]), 
6
   size is the total size of the new array (array_new[]) */
7
 
8
   scanf("%d", &n1); //Get the size of first array from test data and store it in n1.
9
   
10
   for (i = 0; i < n1; i++)
11
      scanf("%d", &arr1[i]); //Accepts the values for first array 
12
 
13
   scanf("%d", &n2); //Get the size of second array from test data and store it in n2.
14
   
15
   for (i = 0; i < n2; i++)
16
      scanf("%d", &arr2[i]); //Accepts the values for second array
17
scanf("%d", &n2); //Get the size of second array from test data and store it in n2.
18
   for (i = 0; i < n2; i++)
19
      scanf("%d", &arr2[i]); //Accepts the values for second array
20
//Merge two arrays
21
int j;
22
for (i=0;i<n1;++i)
23
array_new[i]=arr1[i];
24
size =  n1 + n2;
25
for(i=0, j=n1; j<size && i<n2; ++i, ++j)
26
array_new[j] = arr2[i];
0
//Printing after merging
1
2
for (i = 0; i < size; i++) {
3
      printf("%d\n", array_new[i]);
4
   }
5
6
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
3
10
20
30
4
40
50
60
70
10\n
20\n
30\n
40\n
50\n
60\n
70
10\n
20\n
30\n
40\n
50\n
60\n
70\n
Passed after ignoring Presentation Error
Test Case 2
4
9
7
6
5
2
30
50
9\n
7\n
6\n
5\n
30\n
50
9\n
7\n
6\n
5\n
30\n
50\n
Passed after ignoring Presentation Error



Week-06 Program-04

Due on 2025-09-04, 23:59 IST
Write a C Program to delete duplicate elements from an array of integers.
Your last recorded submission was on 2025-08-29, 17:04 IST
Select the Language for this assignment. 
1
#include<stdio.h>
2
 
3
int main() 
4
{
5
   int array[50], i, size;
6
 
7
   scanf("%d", &size); /*Accepts the size of array from test case data */
8
9
   for (i = 0; i < size; i++)
10
   scanf("%d", &array[i]); /* Read the array elements from the test case data */
11
int j, k;
12
   for (i = 0; i < size; i++) {
13
      for (j = i + 1; j < size;) {
14
         if (array[j] == array[i]) {
15
            for (k = j; k < size; k++) {
16
               array[k] = array[k + 1];
17
            }
18
            size--;
19
         } else
20
            j++;
21
      }
22
   }
0
for (i = 0; i < size; i++) {
1
      printf("%d\n", array[i]);
2
   }
3
4
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
5
50
60
30
20
30
50\n
60\n
30\n
20
50\n
60\n
30\n
20\n
Passed after ignoring Presentation Error
Test Case 2
6
40
20
50
30
20
10
40\n
20\n
50\n
30\n
10
40\n
20\n
50\n
30\n
10\n
Passed after ignoring Presentation Error