Skip to main content

Week 9 Programming Assignment : Problem Solving Through Programming In C 2023

  


What is Problem Solving Through Programming In C?


Problem-solving through programming in C is a course of action where the students learn to apply the concepts of programming to solve problems that can be formulated as algorithms. The course primarily focuses on using the programming language C to develop algorithms and solve problems. The process involves identifying the problem, breaking it down into smaller sub-problems, and designing an algorithm to solve each of them. The algorithm is then translated into a program written in C, which can be executed to obtain the desired results.

The course typically covers the basic concepts of programming in C, such as variables, data types, operators, conditional statements, loops, functions, arrays, and pointers. Students learn how to use these concepts to solve problems such as sorting, searching, mathematical operations, string manipulation, and data structures. They also learn about algorithmic complexity and how to measure the efficiency of their programs.

Problem-solving through programming in C is a crucial skill for anyone who wants to pursue a career in computer science or related fields. It helps students develop their analytical and logical thinking skills, which are essential for solving complex problems. It also provides a foundation for learning other programming languages and concepts.

This approach can be used to solve a wide range of problems, from simple arithmetic calculations to complex algorithms and data structures. The key to success in problem-solving through programming in C is to have a strong understanding of the language, good coding practices, and the ability to think logically and creatively to solve problems.

Week-09 Program-01

Due on 2023-03-30, 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 there are 4 elements in the array 5 6 5 7
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.

Solution :

for (c = 0; c < n; c++)
    {
      if (array[c] == search)
      {
         printf("%d is present at location %d.\n", search, c+1);
         count++;
      }
    }
   if (count == 0)
      printf("%d is not present in the array.\n", search);
   else
      printf("%d is present %d times in the array.\n", search, count);

   return 0;
}


Week-09 Program-02

Due on 2023-03-30, 23:59 IST
Write a C program to marge two given sorted arrays (sorted in ascending order).
The code for input and output is already written. You have to write the merge function so that the merged array is displayed in ascending order.

Solution :

void merge(int a[], int m, int b[], int n, int sorted[]) 
{
    int i = 0, j = 0, k = 0;

    // Compare elements of both arrays and store them in sorted order in the merged array
    while (i < m && j < n) 
    {
        if (a[i] <= b[j]) 
        {
            sorted[k++] = a[i++];
        } 
        else 
        {
            sorted[k++] = b[j++];
        }
    }

    // Copy the remaining elements of array a (if any) to the merged array
    while (i < m) 
    {
        sorted[k++] = a[i++];
    }

    // Copy the remaining elements of array b (if any) to the merged array
    while (j < n) 
    {
        sorted[k++] = b[j++];
    }
}


Week-09 Program-03

Due on 2023-03-30, 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.

Solution :

int first, last, middle;
   first = 0;
   last = n - 1;
   middle = (first+last)/2;

   while (first <= last) {
      if (array[middle] < search)
         first = middle + 1;
      else if (array[middle] == search) {
         printf("%d found at location %d.\n", search, middle+1);
         break;
      }
      else
         last = middle - 1;

      middle = (first + last)/2;
      }
   if (first > last)
      printf("Not found! %d isn't present in the list.\n", search);

     return 0;
      }


Week-09 Program-04

Due on 2023-03-30, 23:59 IST
Write a C program to reverse an array by swapping the elements and without using any new array.

Solution :

int temp, end;
   end = n - 1;
   for (c = 0; c < n/2; c++) {
    temp       = array[c];
    array[c]   = array[end];
    array[end] = temp;

    end--;
  }

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of the best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND THE 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.

Problem-Solving Through Programming In CAnswers
Assignment 1Click Here
Assignment 2Click Here
Assignment 3Click Here
Assignment 4Click Here
Assignment 5Click Here
Assignment 6Click Here
Assignment 7Click Here
Assignment 8Click Here
Assignment 9Click Here
Assignment 10NA
Assignment 11NA
Assignment 12NA

Comments

Popular posts from this blog

Week 3 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W3_Programming_Qs-1 Due on 2023-02-16, 23:59 IST Consider the program below. Fill in the bl...

Week 11 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...

Week 4 Programming Assignment : The Joy of Computing using Python 2023

  What is The Joy of Computing using Python? Python is a popular programming language that is easy to learn and widely used for various applications such as web development, data science, and artificial intelligence. Learning Python can be a joyous experience as it allows you to create your own programs, automate tasks, and solve real-world problems. Here are some tips to help you experience the joy of computing using Python: Start with the basics: Before diving into advanced topics, it is essential to learn the basics of Python such as syntax, data types, and control structures. This will help you build a strong foundation and make it easier to learn more advanced topics. Practice coding: The more you practice coding, the better you will get at it. You can start by writing simple programs and gradually move on to more complex ones. There are also many online resources such as coding challenges and competitions that can help you improve your coding skills. Learn from others: There ...

Week 2 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W2_Programming_Qs-1 Due on 2023-02-09, 23:59 IST Consider the program below. • Fill in th...

Week 1 Programming Assignment : Programming in Modern C++ 2023

  What is Programming in Modern C++? This course introduces problem-solving and programming using the C++ programming language. The topics include: Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.  Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants. Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed. Standard Library of C++. The string, vector, and map classes. W1_Programming_Qs_1 Due on 2023-02-09, 23:59 IST Consider the program below. • Fill in the ...

Week 2 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...

Week 9 Programming Assignment : Programming in JAVA 2023

  What is Programming in Java? Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications. Here are some key features and concepts of Java programming: Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data. Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development. Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code. Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can re...