**NPTEL** **Problem solving through Programming In C **Week 6 All Programming Assignment Solutions | Swayam 2022. With the growth of Information and Communication Technology, there is a need to develop large and complex software.

**ABOUT THE COURSE:**

- Formulate simple algorithms for arithmetic and logical problems
- Translate the algorithms to programs (in C language)
- Test and execute the programs and correct syntax and logical errors
- Implement conditional branching, iteration and recursion
- Decompose a problem into functions and synthesize a complete program using divide and conquer approach
- Use arrays, pointers and structures to formulate algorithms and programs
- Apply programming to solve matrix addition and multiplication problems and searching and sorting problems
- Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration

**COURSE LAYOUT**

**Week 1 :**Introduction to Problem Solving through programs, Flowcharts/Pseudo codes, the compilation process, Syntax and Semantic errors, Variables and Data Types**Week 2 :**Arithmetic expressions, Relational Operations, Logical expressions; Introduction to Conditional Branching**Week 3 :**Conditional Branching and Iterative Loops**Week 4 :**Arranging things : Arrays**Week 5 :**2-D arrays, Character Arrays and Strings**Week 6 :**Basic Algorithms including Numerical Algorithms**Week 7 :**Functions and Parameter Passing by Value**Week 8 :**Passing Arrays to Functions, Call by Reference**Week 9 :**Recursion**Week 10 :**Structures and Pointers**Week 11 :**Self-Referential Structures and Introduction to Lists**Week 12 :**Advanced Topics

Once again, thanks for your interest in our online courses and certification. Happy learning!

#### Course Name : “**Problem Solving through Programming In C 2022**”

**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);

` ````
```#include
int main()
{
int i, n, largest;
int arr[100];
scanf("%d", &n);
for(i = 0; i< n; ++i)
{
scanf("%d", &arr[i]);
}
largest = arr[0];
for(i = 1; i < n; ++i)
{
if(largest < arr[i])
largest = arr[i];
}
printf("Largest element = %d", largest);
return 0;
}

#### Course Name : “**Problem Solving through Programming In C**”

**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.

` ````
```#include
int main()
{
int arr[20], i, n;
scanf("%d", &n);
for(i = 0; i< n; i++)
scanf("%d", &arr[i]);
int j, temp;
j = i - 1; // last Element of the array
i = 0; // first element of the array
while(i < j)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j--;
}
for(i = 0; i< n; i++)
{
printf("%d\n", arr[i]); // For printing the array elements
}
return(0);
}

#### Course Name : “**Problem Solving through Programming In C**”

**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.

` ````
```#include
int main()
{
int arr1[20], arr2[20], array_new[40], n1, n2, size, i;
scanf("%d", &n1);
for(i = 0; i< n1; i++)
scanf("%d", &arr1[i]);
scanf("%d", &n2);
for(i = 0; i< n2; i++)
scanf("%d", &arr2[i]);
int j;
for(i=0;i

#### Course Name : “**Problem Solving through Programming In C**”

**Question : 4 **Write a C Program to delete duplicate elements from an array of integers.

` ````
```#include
int main()
{
int array[50], i, size;
scanf("%d", &size);
for(i = 0; i< size; i++)
scanf("%d", &array[i]);
int j, k;
for(i = 0; i < size; i++) {
for(j = i + 1; j < size;) {
if(array[j] == array[i]) {
for(k = j; k < size; k++) {
array[k] = array[k + 1];
}
size--;
}
else
j++;
}
}
for(i = 0; i< size; i++)
{
printf("%d\n", array[i]);
}
}