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

  Why agile approaches to systems design are increasingly used

Discuss why prototyping and agile approaches to systems design are increasingly being used instead of traditional waterfall approaches.

  Derive the correction circuit needed and simplify it

Implement the full adder using a 3-to-8 decoder. Use two 4-to-1 multiplexers to implement a full adder.

  When and why would you consider using multiple nics

Describe a situation where you would purchase a work station with a built in NIC and a situation where you would use an expansion card.

  Object-oriented development environment

Develop a problem-based strategy for creating and applying programmed solutions using an object-oriented paradigm and use an object-oriented development environment in the development, testing and debugging of an object-oriented application.

  Examine the editor available on unix and personal computer

Examine the editor available on Unix and personal computer & Does it have batch-oriented commands?

  How many inputs could we process in t seconds

How many inputs could we process on the new machine in t seconds? How many inputs could we process in t seconds?

  Display the projected semester tuition amount for next years

Write a function named tuition_increase with a loop that displays the projected semester tuition amount for the next 5 years.

  What roles public safety plays in physical security

What roles do you believe public safety plays in physical security? (Please cite 2 credible sources to support your responses)

  How much of a disadvantage computer scientists have

Philosophy is deeply rooted in the History of Computers starting with Leibniz and his concept of binary. Leibniz's dream imagines Armchair Philosopher to be left alone with his thoughts while machines take care of all the other menial tasks requir..

  Discuss potential sources of conflict with an interface

One challenge pertains to sources of conflict in NCLDs. Discuss potential sources of conflict with an interface that you frequently use and devise a solution for preventing the conflicts.

  What is time estimate

How does an estimator arrive at a time estimate for a particular task.

  What must be saved before the isr is run

This interrupt is generated by the CPU when the execution of an instruction produces a condition which prevents it from completing.

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