Question

1 11 AaBbCcDdee AaBbCcDdee AaBbCcDc Aaf Normal No Spacing Heading 1 WSU ID: Long Answer 1. Write a C++ program (along with he

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;
void smallToFront(int arr[],int size)
{
   int small,index,tmp;
   small=arr[0];
   for(int i=0;i<size;i++)
   {
       if(small>=arr[i])
       {
           index=i;
           small=arr[i];
       }     
   }
   tmp=arr[0];
   arr[0]=small;
   arr[index]=tmp;
   for(int i=0;i<size;i++)
   {
       cout<<arr[i]<<" ";
   }
}
int main()
{
   const int size=5,size1=15;
   int arr[]={11,22,22,4,42};
   cout<<"Output for First array:\n";
   smallToFront(arr,size);
   cout<<"\n";
   int arr1[]={90,21,72,21,42,11,22,11,10,11,90,10,14,15,55};
   cout<<"Output for Second array:\n";
   smallToFront(arr1,size1);
   return 0;
}

OUTPUT:-

Output for First array:
4 22 22 11 42
Output for Second array:
10 21 72 21 42 11 22 11 10 11 90 90 14 15 55

Add a comment
Know the answer?
Add Answer to:
1 11 AaBbCcDdee AaBbCcDdee AaBbCcDc Aaf Normal No Spacing Heading 1 WSU ID: Long Answer 1....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SEE AL AaBbCcDdEe AaBbCcDdEe No Spacing AaBbCcDc AaBbc Heading 1 Headi Normal 8. To hardcode the...

    SEE AL AaBbCcDdEe AaBbCcDdEe No Spacing AaBbCcDc AaBbc Heading 1 Headi Normal 8. To hardcode the current time into a cell: a. Ctrl + Shift + b. Ctrl+Enter +D c. Alt +T d. Ctrl+T 9. If you have formatted a cell as %, which of the following would yield 3%? b. .03 C. - Ctrl +1+3/100 d. 3 + Ctrl + P e. a and b 10. In Excel, the default setting for numbers is: a. Right justified b. Center...

  • The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random...

    The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...

  • C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with...

    C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with each element representing its column and row value, starting from 1. So the element at the first column and the first row will be 11. If either length is out of the range, simply return a null. For exmaple, if colLength = 5 and rowLength = 4, you will see: 11 12 13 14 15 21 22 23 24 25 31 32 33 34...

  • ABCcDdEe AaBbccdee No Spacing AaBbCcDc AaBbCcDdEk AaBb Heading 1 Heading 2 Title AaBb CcDdEe Subtitle Normal...

    ABCcDdEe AaBbccdee No Spacing AaBbCcDc AaBbCcDdEk AaBb Heading 1 Heading 2 Title AaBb CcDdEe Subtitle Normal Case 4: A 64 year-old man complained of chest pain and fainting two days before admission. He had several prior admissions for severe chest pain, which was relieved by nitroglycerin. On the day of admission he was nauseated and felt numbness in the left arm. He was admitted to coronary care unit, and his serial enzyme studies are shown below. Lab Data: Day 2...

  • What am i doing wrong? can some take a look and tell me what should i...

    What am i doing wrong? can some take a look and tell me what should i change? in which line and how to fix it? Exercise 71130X WORK AREA RESULTS l import java.util.scanner; 3 class Numbersearch 5 public static void main (String args) 7 scanner scnew scanner (System.in); 9 System.out.println"Enter length of array 10 11 int size - sc.nextInt() 12 13 int arrnew intisize]; 14 15 for (int i -0; i < size; i+t) 17 System.out.println("Enter number for array index"+i:")i...

  • You are making a .h file. Implement a recursive binary search function. bSearch passes in an...

    You are making a .h file. Implement a recursive binary search function. bSearch passes in an array of integers, the size of the array, and the value the function is searching for. The function should return the index where found or -1 if not found. You will want to implement a recursive helper function that passes in the array, the value to be located, and the beginning and ending of the range of values to search within. Use the provided...

  • 02. Log N Vector Due Sunday by 11:59pm Points 149 O(log(N)) Vector std::vector is pretty cool...

    02. Log N Vector Due Sunday by 11:59pm Points 149 O(log(N)) Vector std::vector is pretty cool but it has one big problem: every once in a while, push_back has to create a whole new array and copy a bunch of elements which is O(n)! Luckily, we can do better, in terms of Big-O. The goal of this homework is to write a class that behaves like a vector but without the O(n) push_back. Whenever we run out of space, we'll...

  • I need to develop the 7 functions below into the main program that's given on top...

    I need to develop the 7 functions below into the main program that's given on top Write a C program to create array, with random numbers and perform operations show below. Il Project 3 (53-20). 1 Projects CS5,00 This file contains the function Programcution Dagine and one include <timo // Defining some constants definer_SIZE 20 define LOVE LIMIT 1 eine UPR UNIT define TALSE eine Tut 1 wold randomizery (int[], int, Int, int) wold pinay in. St, Int); En find...

  • Write a C++ function, smallestIndex, that takes as parameters an int array and its size and...

    Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occurrence of the smallest element in the array. To test your function, write a main that prompts a user for a list of 15 integers and outputs the index and value of the first occurrence of the smallest value. The program should print out Enter 15 integers: The position of the first occurrence of the smallest element in...

  • Question 1) Suppose a program has the following code: const int X = 2, Y =...

    Question 1) Suppose a program has the following code: const int X = 2, Y = 3; int sum; int values[X][Y] = {{1, 2, 3},                                  {4, 5, 6}}; for(int i=0; i<X; i++) {      sum=0;      for(int j=0; j<Y; j++)         sum+=values[i][j];    cout<<sum<<endl; } What is this program getting the sum of? Group of answer choices D-) The columns of the 2D array C-) The rows of the 2D array A-) All of the elements of the 2D...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT