Change unix file permission on unix

Assignment Help C/C++ Programming
Reference no: EM13921665

Modify selection_sort.c so that it includes the following functions:

void selection_sort(int *a, int n);
int *find_largest(int *a, int n);
void swap(int *p, int *q);

selection_sort function: it should call find_largest function and swap function.

find_largest function: when passed an array of length n, the function will return a pointer to the array's largest element. The function should use pointer arithmetic - not subscripting - to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.

swap function: when passed the addresses of two variables, the function should exchange the values of the variables:
swap(&i, &j); /* exchange values of i and j */

Your program will call find_largest function and swap function in selection_sort function.

A vector is an ordered collection of values in mathematics. An array is a very straightforward way to implement a vector on a computer. Two vectors are multiplied on an entry-by-entry basis, e.g. (1, 2, 3) * (4, 5, 6) = (4, 10, 18).

Write a program that include the following functions. The functions should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the functions.

void multi_vec (int *v1, int *v2, int *v3, int n);
int comp_vec(int *v1, int *v2, int n);

The multi_vec function multiplies vectors v1 and v2 and stores the result in v3. n is the length of the vectors.

The comp_vec function compares v1 and v2, return 1 if vectors v1 and v2 are equal (their corresponding components are equal), and 0 otherwise. n is the length of the vectors.

In the main function, ask the user to enter the length of the vectors, declare two arrays with the length, read in the values for two vectors, and call the two functions to compute the multiplication and comparison of them. The main function should display the result.

Enter the length of the vectors: 5

Enter the first vector: 3 4 9 1 4

Enter the second vector: 5 7 2 6 8

Output:

The multiplication of the vectors is: 15 28 18 6 32

The vectors are not the same.

Before you submit:

1. Compile with -Wall. Be sure it compiles on circe with no errors and no warnings.

gcc -Wall selection_sort.c
gcc -Wall vector.c

2. Be sure your Unix source file is read & write protected. Change Unix file permission on Unix:

chmod 600 selection_sort.c
chmod 600 vector.c

3. Test your program with the shell scripts on Unix:

chmod +x try_sort
./try_sort
chmod +x try_vector
./try_vector

Reference no: EM13921665

Questions Cloud

Requires initial fixed asset investment : Cochrane, Inc., is considering a new three-year expansion project that requires an initial fixed asset investment of $2,400,000. The fixed asset will be depreciated straight-line to zero over its three-year tax life, after which time it will be worth..
Potential advantage of electronic communication : Software that allows users to view others' real-time availability and readiness to communicate is known as
Pert network : In a PERT network, the earliest (activity) start time is the: earliest time that an activity can be finished without delaying the entire project
Businesses of engaging in voluntary responsibilities : Which of the following is not a benefit to businesses of engaging in voluntary responsibilities?
Change unix file permission on unix : Modify selection_sort.c so that it includes the following functions:
Describe the elements oflewin force field analysis model : Describe the elements ofLewin's force field analysis model. APA Format, 200 Words Minimum, Please cite references
Distinguish between returns to scale and returns to a factor : Distinguish between returns to scale and returns to a factor. Your company currently uses steel and aluminum in a production process. Steel costs $.50 per pound, and aluminum costs $1.00 per pound.
Demand in market determine the currencys value : A ________ exchange rate is the quoted price for a unit of foreign currency to be delivered within a very short period of time. The Government does not set a _______ exchange rate, which means that supply and demand in the market determine the curren..
Simmons companies issued bonds with a face value : Write a brief memo explaining whether the effective interest rate method or the straight line method will produce the highest amount of interest expense recognized on the 2013 income statement.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd