Array Processing. In this problem, you have two tasks: To create the header file, arrayOptn.h, and add the function declarations of the following functions listed below. To create the file, arrayOptn.c, which implements the functions in the arrayOptn.h You are already provided with the main() function. Do not edit anything there in the main.c file.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Array Processing.

In this problem, you have two tasks:

  1. To create the header file, arrayOptn.h, and add the function declarations of the following functions listed below.
  2. To create the file, arrayOptn.c, which implements the functions in the arrayOptn.h

You are already provided with the main() function. Do not edit anything there in the main.c file.


  • 5 - void printElementsInAscending(int arr[], int count)
    • Parameters:
      • int arr[] - a reference to the array to be processed
      • int count - the number of elements in the array
    • Description:
      • Prints all the elements of the passed array in ascending order
      • The format of the message is: "Elements: el1 el2 el3 elx" where e1, el2, el3, elx are the current elements of the array.
  • 6 - void printElementsInDescending(int arr[], int count)
    • Paramters:
      • int arr[] - a reference to the array to be processed
      • int count - the number of elements in the array
    • Description:
      • Prints all the elements of the passed array in descending order
      • The format of the message is: "Elements: el1 el2 el3 elx" where e1, el2, el3, elx are the current elements of the array

main.c:

#include<stdio.h>
#include "arrayOptn.h"

#define MAX_SIZE 100

int main(void) {
    int array[MAX_SIZE];
    int count = 0;
    
    int numberOfCommands;

    printf("Enter number of commands: ");
    scanf("%d", &numberOfCommands);
    
    printf("Enter count of elements: ");
    scanf("%d", &count);
    
    printf("\n");
    
    int command;
    int elem, k;
    for(int c = 1; c <= numberOfCommands; c++) {
      printf("COMMAND #: ");
      scanf("%d", &command);
      
      switch(command) {
        case 1:
          createArray(array, count, MAX_SIZE);
          printf("\n");
          break;
        case 2:
          printArray(array, count);
          printf("\n\n");
          break;
        case 3:
          printf("Enter element: ");
          scanf("%d", &elem);
          printf("Return Value: %d", locateIndex(array, count, elem));
          printf("\n\n");
          break;
        case 4:
          printf("Enter element: ");
          scanf("%d", &elem);
          printf("Return Value: %d", locateElement(array, count, elem));
          printf("\n\n");
          break;
        case 5:
          printElementsInAscending(array, count);
          printf("\n\n");
          break;
        case 6:
          printElementsInDescending(array, count);
          printf("\n\n");
          break;
        case 7:
          printf("Enter element: ");
          scanf("%d", &elem);
          printf("Enter position: ");
          scanf("%d", &k);
          printf("Return Value: %d", insertAtPos(array, &count, elem, k));
          printf("\n\n");
          break;
        case 8:
          printf("Enter element: ");
          scanf("%d", &elem);
          printf("Return Value: %d", insertFront(array, &count, elem));
          printf("\n\n");
          break;
        case 9:
          printf("Enter position: ");
          scanf("%d", &k);
          printf("Return Value: %d", removeAtPos(array, &count, k));
          printf("\n\n");
          break;
        case 10:
          printf("Enter element: ");
          scanf("%d", &elem);
          printf("Return Value: %d", removeElement(array, &count, elem));
          printf("\n\n");
          break;
        case 11:
          printf("Return Value: %d", removeFront(array, &count));
          printf("\n\n");
      }
    }

    return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY