Problem Solving Through Programming In C Week 8 Solutions 2024

ABOUT THE COURSE :

Problem Solving Through Programming In C Week 6 Solutions

Disclaimer: The answers to these questions are provided for educational and informational purposes only. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.

This course is aimed at enabling the students to
    1. Formulate simple algorithms for arithmetic and logical problems 
    2. Translate the algorithms to programs (in C language) 
    3. Test and execute the programs and correct syntax and logical errors
    4. Implement conditional branching, iteration and recursion
    5. Decompose a problem into functions and synthesize a complete program using divide and conquer approach
    6. Use arrays, pointers and structures to formulate algorithms and programs
    7. Apply programming to solve matrix addition and multiplication problems and searching and sorting problems
    8. Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration

Summary
Course Type Elective
Duration 12 weeks
Category Computer Science and Engineering
Start Date 22 Jan 2024
End Date 12 Apr 2024
Exam Registration Ends 16 Feb 2024
Exam Date 21 Apr 2024 IST

Assignment Solutions :
Programming Assignment :

Week-06: Program-01 :

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 <stdio.h>
int main()
{
    int i, n, largest;
    int arr[100];

    scanf("%d", &n); /*Accepts total number of elements from the test data */

    for(i = 0; i < n; ++i)
    {
       scanf("%d", &arr[i]); /* Accepts the array element from test data */
    }

    largest = arr[0];
    for(i = 1; i < n; ++i)
    {
        if(largest < arr[i])
        largest = arr[i];
    }
    printf("Largest element = %d", largest);
    return 0;
}

Week-06: Program-02 :

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<stdio.h>
int main()
{
   int arr[20], i, n;
   scanf("%d", &n); /* Accepts the number of elements in the array */

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

Week-06: Program-03 :

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<stdio.h>

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 < 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];

    for (i = 0; i < size; i++)
        printf("%d\n", array_new[i]);
}

Week-06: Program-04 :

Write a C Program to delete duplicate elements from an array of integers.

#include<stdio.h>

int main()
{
   int array[50], i, size;

   scanf("%d", &size); /*Accepts the size of array from test case data */

   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]);
   }
}

CRITERIA TO GET A CERTIFICATE :
  1. Average assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
  2. Exam score = 75% of the proctored certification exam score out of 100
  3. Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met,you will not get the certificate even if the Final score >= 40/100.

Join With Us On :

Join Now


Previous Year Questions Now to Boost Your Exam Performance

LOADS OF LOGIC