The user for a positive number n representing the number

Assignment Help Computer Engineering
Reference no: EM132194770

Question :

Write a C program called sort.c that first prompts the user for a positive number n representing the number of numbers to be sorted.

Next, it prompts the user to enter the numbers in an arbitrary order and store them in an array of size n (numbers[n]).

The program then takes the following approach to sort the numbers in the array:

it stores the value of n in a temporary variable temp,

it searches for the largest number in the array, starting with position 0 and ending with position temp-1.

To find largest element in the array write a function

int getMax (int numbers[], int n);

(or)

try using int getMax (*list, int n);//this involves the concept of pointers.

This function determines the largest value in an array and returns its location in the array. The parameter n indicates the number of values in the array.

The parameter list is the array of integers.

it then switches the field that stores the largest value with the field indexed by temp-1, this is done by employing a function

void switchValue ( int *a, int *b )

the program decrements temp by 1 (temp--),

the program repeats steps {b-d} until temp is decremented to 1 in step d.

Output: Print the sorted array (ascending order)

Reference no: EM132194770

Questions Cloud

Write a program to create two files : Write a C++ program to create two files named abc.txt which contains the text I love C++ Programming and def.txt which contains the text.
A program for the frequency histogram : Write a C++ program (c++14). ask the user give some inputs. and then output the frequency histogram of them.
Write a c program that defines a data type : Write a C program that defines a data type (structure ) called course which includes the following fields on Computer Science courses.
Calculate the product of the two integers : The function takes two integers as arguments and calculates the product of the two integers. The function will return the product.
The user for a positive number n representing the number : Write a C program called sort.c that first prompts the user for a positive number n representing the number of numbers to be sorted.
Ask the user to enter a time in the format : Write a c++ program that asks the user to enter a time in the format HH:MM, if all digits are the same print , "you lucky".
Mean an improvement in economic welfare : Explain why a high economic growth rate does not necessarily mean an improvement in economic welfare
Discuss differences in cash flow : Why are stocks considered riskier than bonds? Be sure to discuss differences in cash flow.
Announcement but before the jobs : The unemployment rate after the announcement but before the jobs are filled will be %. Enter your responses rounded to one decimal place.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Compare and contrast agile development approaches

Compare and contrast agile development approaches. Compare problem-solving techniques in agile environments. Use technology and information resources.

  Write a help module for an inventory control system

In this assignment, you will develop appropriate messages to the user and write a Help module for an Inventory Control system.

  Give the pseudocode for the flowchart

make a flowchart and give the pseudocode for searching an array for a specified value.

  Show the schematic diagram of memory system

In each of the designs in Problem, show the physical location of the following addresses: 0, 48, 356, and 8192.

  Generating class diagram and pseudocode

Develop a class named CustomerRecord which holds a customer number, name, and address. Incorporate different methods in order to set the values for each data field and output values for each data field.

  How would you restore the system

Suppose something bad happened on April 26th, 2017. How would you restore the system to 4/26/17 assuming the backups run at night?

  What is the plaintext m

In a public-key system using RSA, you intercept the ciphertext C equal to 128, sent to a user whose public key is e 7, n 527. What is the plaintext M?

  Draw a high-level er diagram for the business statement

For each student we want to know their name, date of birth, contact info and GPA. The contact info includes mailing address, email, and telephone.

  Prepare a report summarizing your research describe why you

q1. cascading style sheets css a multi-featured specification for html offers designers an expedient powerful method to

  Discuss the advantages of backing up to the cloud

Discuss the advantages and disadvantages of backing up to the Cloud. minimum 150 words not including title and reference page.

  Writes your systems private and public ip addresses

Write a script in BASH that automatically writes your system's private (eth0) and public IP addresses to a file within your home directory called ipaddresses.

  The difference between white box and black box testing

What is the difference between white box and black box testing? What is regression testing, and why do we need to perform regression tests?

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