Learn Programming & Prepare for NPTEL Exams...
Swayam Solver is your one-stop destination for NPTEL exam preparation.
NPTEL Problem Solving Through Programming In C - Programming Assignment | July-2024 Week 4 to 8
Week-04: Program-01
Due on 2024-08-22, 23:59 IST
Write a C Program to Find the Smallest Number among Three Numbers (integer values) using Nested IF-Else statement.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
20 30 10
10 is the smallest number.
10 is the smallest number.
Passed
Test Case 2
77 -44 99
-44 is the smallest number.
-44 is the smallest number.
Passed
Week-04: Program-02
Due on 2024-08-22, 23:59 IST
The length of three sides are taken as input. Write a C program to find whether a triangle can be formed or not. If not display “This Triangle is NOT possible.” If the triangle can be formed then check whether the triangle formed is equilateral, isosceles, scalene or a right-angled triangle. (If it is a right-angled triangle then only print Right-angle triangle do not print it as Scalene Triangle).
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
10 4 6
Triangle is not possible
Triangle is not possible
Passed
Test Case 2
7 6 8
Scalene Triangle
Scalene Triangle
Passed
Test Case 3
9 9 9
Equilateral Triangle
Equilateral Triangle
Passed
Week-04 Program-03
Due on 2024-08-22, 23:59 IST
Write a program to find the factorial of a given number using while loop.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
The Factorial of 5 is : 120
The Factorial of 5 is : 120
Passed
Test Case 2
10
The Factorial of 10 is : 3628800
The Factorial of 10 is : 3628800
Passed
Week-04: Program-04
Due on 2024-08-22, 23:59 IST
Write a C program to find power of a number using while loops. The base number (>0) and exponent (>=0) is taken from the test cases.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
4
The result is : 625
The result is : 625\n
Passed after ignoring Presentation Error
Test Case 2
7
3
The result is : 343
The result is : 343\n
Passed after ignoring Presentation Error
Week-05 Program-01
Due on 2024-08-29, 23:59 IST
Write a C program to check whether a given number (N) is a perfect number or not? [Perfect Number - A perfect number is a positive integer number which is equals to the sum of its proper positive divisors. For example 6 is a perfect number because its proper divisors are 1, 2, 3 and it’s sum is equals to 6.]
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
6
6 is a perfect number.
6 is a perfect number.
Passed
Test Case 2
87
87 is not a perfect number.
87 is not a perfect number.
Passed
Week-05 Program-02
Due on 2024-08-29, 23:59 IST
Write a C program to count total number of digits of an Integer number (N).
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
3456
The number 3456 contains 4 digits.
The number 3456 contains 4 digits.
Passed
Test Case 2
570
The number 570 contains 3 digits.
The number 570 contains 3 digits.
Passed
Week-05 Program-03
Due on 2024-08-29, 23:59 IST
Write a C program to check whether the given number(N) can be expressed as Power of Two (2) or not. For example 8 can be expressed as 2^3.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
8
8 is a number that can be expressed as power of 2.
8 is a number that can be expressed as power of 2.
Passed
Test Case 2
46
46 cannot be expressed as power of 2.
46 cannot be expressed as power of 2.
Passed
Week-05 Program-04
Due on 2024-08-29, 23:59 IST
Write a C program to print the following Pyramid pattern upto Nth row. Where N (number of rows to be printed) is taken as input. For example when the value of N is 5 the pyramid will be printed as follows ***** **** *** ** *
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
*****\n
****\n
***\n
**\n
*
*****\n
****\n
***\n
**\n
*\n
Passed after ignoring Presentation Error
Test Case 2
3
***\n
**\n
*
***\n
**\n
*\n
Passed after ignoring Presentation Error
Private Test cases used for Evaluation
Status
Test Case 1
Passed
Test Case 2
Passed
Week-06 Program-01
Due on 2024-09-05, 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);
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
10
50
40
30
20
Largest element = 50
Largest element = 50
Passed
Test Case 2
7
100
50
60
70
90
30
40
Largest element = 100
Largest element = 100
Passed
Week-06 Program-02
Due on 2024-09-05, 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.
Public Test Cases
Input
Expected Output
Actual Output
Status
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 2024-09-05, 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.
Public Test Cases
Input
Expected Output
Actual Output
Status
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 2024-09-05, 23:59 IST
Write a C Program to delete duplicate elements from an array of integers.
Public Test Cases
Input
Expected Output
Actual Output
Status
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
Private Test cases used for Evaluation
Status
Test Case 1
Passed
Test Case 2
Passed
Week 07 Program-01
Due on 2024-09-12, 23:59 IST
Write a C Program to Count Number of Uppercase and Lowercase Letters in a given string. The given string may be a word or a sentence.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
Online NPTEL Course.
Uppercase Letters : 7\n
Lowercase Letters : 10
Uppercase Letters : 7\n
Lowercase Letters : 10
Passed
Test Case 2
National Programme on Technology Enhanced Learning is a joint initiative of the IITs and IISc.
Uppercase Letters : 11\n
Lowercase Letters : 68
Uppercase Letters : 11\n
Lowercase Letters : 68
Passed
Week 07 Program-02
Due on 2024-09-12, 23:59 IST
Write a C program to find the sum of all elements of each row of a matrix.
Example: For a matrix 4 5 6
6 7 3
1 2 3
The output will be
15
16
6
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
3
3
1
1
1
2
2
2
3
3
3
3\n
6\n
9
3\n
6\n
9\n
Passed after ignoring Presentation Error
Test Case 2
2
3
1
2
3
4
5
6
6\n
15
6\n
15\n
Passed after ignoring Presentation Error
Week 07 Program-03
Due on 2024-09-12, 23:59 IST
Write a C program to find subtraction of two matrices i.e. matrix_A - matrix_B=matrix_C.
If the given martix are
2 3 5 and 1 5 2 Then the output will be 1 -2 3
4 5 6 2 3 4 2 2 2
6 5 7 3 3 4 3 2 3
The elements of the output matrix are separated by one blank space
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
3
3
2
3
5
4
5
6
6
5
7
1
5
2
2
3
4
3
3
4
1 -2 3 \n
2 2 2 \n
3 2 3
1 -2 3 \n
2 2 2 \n
3 2 3 \n
Passed after ignoring Presentation Error
Week 07 Program-04
Due on 2024-09-12, 23:59 IST
Write a C program to print lower triangle of a square matrix.
For example the output of a given matrix
2 3 4 will be 2 0 0
5 6 7 5 6 0
4 5 6 4 5 6
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
3
1
2
3
1
2
3
1
2
3
1 0 0 \n
1 2 0 \n
1 2 3
1 0 0 \n
1 2 0 \n
1 2 3 \n
Passed after ignoring Presentation Error
Week 08: Program-01
Due on 2024-09-19, 23:59 IST
Write a C Program to find HCF of 4 given numbers using recursive function
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
100
30
50
70
The HCF is 10
The HCF is 10
Passed
Test Case 2
49
56
147
21
The HCF is 7
The HCF is 7
Passed
Week 08: Program-02
Due on 2024-09-19, 23:59 IST
Write a C Program to find power of a given number using recursion. The number and the power to be calculated is taken from test case
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
2
5^2 is 25
5^2 is 25
Passed
Test Case 2
10
4
10^4 is 10000
10^4 is 10000
Passed
Week-08 Program-03
Due on 2024-09-19, 23:59 IST
Write a C Program to print Binary Equivalent of an Integer using Recursion
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
10
The binary equivalent of 10 is 1010
The binary equivalent of 10 is 1010\n
Passed after ignoring Presentation Error
Test Case 2
257
The binary equivalent of 257 is 100000001
The binary equivalent of 257 is 100000001\n
Passed after ignoring Presentation Error
Week 08: Program-04
Due on 2024-09-19, 23:59 IST
Write a C Program to reverse a given word using function. e.g. INDIA should be printed as AIDNI
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
computer
The string after reversing is: retupmoc
The string after reversing is: retupmoc
Passed
Test Case 2
NPTEL
The string after reversing is: LETPN
The string after reversing is: LETPN
Passed
Week-09 Program-01
Due on 2024-09-26, 23:59 IST
Write a program to print all the locations at which a particular element (taken as input) is found in a list and also print the total number of times it occurs in the list. The location starts from 1. For example: if there are 4 elements in the array 5 6 5 7 If the element to search is 5 then the output will be 5 is present at location 1 5 is present at location 3 5 is present 2 times in the array.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
4
5
6
5
7
5
5 is present at location 1.\n
5 is present at location 3.\n
5 is present 2 times in the array.
5 is present at location 1.\n
5 is present at location 3.\n
5 is present 2 times in the array.\n
Passed after ignoring Presentation Error
Test Case 2
5
67
80
45
97
100
50
50 is not present in the array.
50 is not present in the array.\n
Passed after ignoring Presentation Error
Week-09 Program-02
Due on 2024-09-26, 23:59 IST
Write a C program to search a given element from a 1D array and display the position at which it is found by using linear search function. The index location starts from 1.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
78
90
34
54
98
90
90 is present at location 2.
90 is present at location 2.
Passed
Test Case 2
6
30
40
50
20
90
60
90
90 is present at location 5.
90 is present at location 5.
Passed
Week-09 Program-03
Due on 2024-09-26, 23:59 IST
Write a C program to search a given number from a sorted 1D array and display the position at which it is found using binary search algorithm. The index location starts from 1.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
10
20
30
40
50
40
40 found at location 4.
40 found at location 4.
Passed
Test Case 2
4
44
55
66
77
10
Not found! 10 isn't present in the list.
Not found! 10 isn't present in the list.
Passed
Week-09 Program-04
Due on 2024-09-26, 23:59 IST
Write a C program to reverse an array by swapping the elements and without using any new array.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
4
10
20
30
40
Reversed array elements are:\n
40\n
30\n
20\n
10
Reversed array elements are:\n
40\n
30\n
20\n
10\n
Passed after ignoring Presentation Error
Test Case 2
5
50
60
40
30
20
Reversed array elements are:\n
20\n
30\n
40\n
60\n
50
Reversed array elements are:\n
20\n
30\n
40\n
60\n
50\n
Passed after ignoring Presentation Error
Week-10 Program-01
Due on 2024-10-03, 23:59 IST
Write a C code to check if a 3 x 3 matrix is invertible. A matrix is not invertible if its determinant is 0.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
1
2
3
4
5
6
7
8
9
The given matrix is not invertible
The given matrix is not invertible
Passed
Test Case 2
1
0
5
2
1
6
3
4
0
The given matrix is invertible
The given matrix is invertible
Passed
Week-10 Program-02
Due on 2024-10-03, 23:59 IST
Write a C program to sort a 1D array using pointer by applying Bubble sort technique.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
6
-10
90
30
20
-100
50
-100\n
-10\n
20\n
30\n
50\n
90
-100\n
-10\n
20\n
30\n
50\n
90\n
Passed after ignoring Presentation Error
Week-10 Program-03
Due on 2024-10-03, 23:59 IST
Write a C program to sort a given 1D array using pointer in ascending order.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
20
40
50
30
10
10\n
20\n
30\n
40\n
50
10\n
20\n
30\n
40\n
50\n
Passed after ignoring Presentation Error
Week-10 Program-04
Due on 2024-10-03, 23:59 IST
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
2
Root = 3.465754
Root = 3.465754
Passed
Test Case 2
5
Root = 1.908690
Root = 1.908690
Passed
Week-11 Program-01
Due on 2024-10-10, 23:59 IST
Write a C program to reverse a word using Recursion. Input to the program is a string that is to be taken from the user and output is reverse of the input word. Note that you have to use recursion.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
KHARAGPUR
The reversed string is : RUPGARAHK
The reversed string is : RUPGARAHK\n
Passed after ignoring Presentation Error
Week-11 Program-02
Due on 2024-10-10, 23:59 IST
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
25
The respective value of the variable v is: 56.42
The respective value of the variable v is: 56.42
Passed
Week-11 Program-03
Due on 2024-10-10, 23:59 IST
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
0
1
The integral is: 0.335000
The integral is: 0.335000
Passed
Week-11 Program-04
Due on 2024-10-10, 23:59 IST
Write a C program to check whether the given input number is Prime number or not using recursion. So, the input is an integer and output should print whether the integer is prime or not. Note that you have to use recursion.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
13
13 is a prime number
13 is a prime number\n
Passed after ignoring Presentation Error
Test Case 2
40
40 is not a prime number
40 is not a prime number\n
Passed after ignoring Presentation Error
Week-12: Program-01
Due on 2024-10-17, 23:59 IST
Write a program in C to find the factorial of a given number using pointers.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
The Factorial of 5 is: 120
The Factorial of 5 is: 120\n
Passed after ignoring Presentation Error
Test Case 2
10
The Factorial of 10 is: 3628800
The Factorial of 10 is: 3628800\n
Passed after ignoring Presentation Error
Week-12: Program-02
Due on 2024-10-17, 23:59 IST
Write a C program to print the Record of the Student Merit wise. Here a structure variable is defined which contains student rollno, name and score.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
3
1
Santanu
700
2
Aparna
550
3
Vivek
900
The Merit List is :\n
3 Vivek 900\n
1 Santanu 700\n
2 Aparna 550
The Merit List is :\n
3 Vivek 900\n
1 Santanu 700\n
2 Aparna 550\n
Passed after ignoring Presentation Error
Week-12: Program-03
Due on 2024-10-17, 23:59 IST
Write a C program to store n elements using Dynamic Memory Allocation - calloc() and find the Largest element.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
5
200
300
500
100
400
Largest element = 500.00
Largest element = 500.00
Passed
Week-12: Program-04
Due on 2024-10-17, 23:59 IST
Write a C program to add two distance given as input in feet and inches.
Public Test Cases
Input
Expected Output
Actual Output
Status
Test Case 1
40
11
10
11
Sum of distances = 51 feet 10 inches
Sum of distances = 51 feet 10 inches
Passed
Test Case 2
10
5
20
5
Sum of distances = 30 feet 10 inches
Sum of distances = 30 feet 10 inches
Passed
No comments:
Post a Comment
Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.
No comments:
Post a Comment
Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.