Compute the multiplication and comparison of them

Assignment Help Basic Computer Science
Reference no: EM13854473

Problem 1. This program will be graded based on whether the required functionality were implemented correctly instead of whether it produces the correct output, for the functionality part (80% of the grade).

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.

Problem 2.

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.

Reference no: EM13854473

Questions Cloud

Gender and culture paper : Students will complete a 5 page paper (double spaced, 12pt., Times New Roman) paper on how sex and/or gender operate in a specific culture or subculture. Any culture is acceptable as long as conducting the research does not pose harm to you or anyone..
Discuss the classification of functionalities used : Discuss the classification of functionalities used in this article and leading vendors. Why are these classifications used and what do they mean
Briefly state how the cultures of both civilzations : Why did both the Mesopotamian and Egyptian civilzations emerge where they did, and what do you think were the biggest contributions of these two civilizations by 600 B.C.E. Briefly state how the cultures of both civilzations were preserved and spr..
What are risks associated with nikes core marketing strategy : What are the pros, cons, and risks associated with Nike"s core marketing strategy?
Compute the multiplication and comparison of them : Compute the multiplication and comparison of them. The main function should display the result.
A journalist was interested in college students : A journalist was interested in college students' knowledge of current events. The journalist compared a large group of college students to the general public using a questionnaire about recent items in the news. In this study, she tested large number..
Describe in detail a bad decision : Describe in detail a bad decision that you made at work in the past, or any work-related decision that you wish you could "do over." Be sure to indicate your career field, as you describe this decision. Analyze that bad decision using Steps 1-7 of th..
Financial statements and the closing process : The information needed to prepare the income statement is found in the Income Statement columns of the work sheet. Revenue is shown first, followed by an itemized and totaled list of expenses. Net income may be calculated or copied from the Income..
Design a raptor program that uses an array : Design a Raptor program that uses an array to store 5 values entered by the user and then displays the numbers in reverse order. Use two loops: one for reading the user entered values into the array

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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