Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include #define MAX_SIZE 100 using namespace std; void BubbleSort (int arr[], int n) { int i, j; int temp; for (i =

image text in transcribed

#include #include #include #include

#define MAX_SIZE 100

using namespace std;

void BubbleSort (int arr[], int n) { int i, j; int temp; for (i = 0; i j+1. if (arr[j] > arr[j+1]) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp;

} } } }

int main(){

string filename; int *data = new int[MAX_SIZE]; int count = 0;

//Your solution here

// I have added this part

// ifstream File; // File.open("input.txt"); // while(!File.eof()) { // File >> data[count]; // count++; // } // File.close();

// I have this part written not sure why Im not getting the right answer

// Call the sort function here

// BubbleSort(data, count); // I have added to the code

// this is what i have added ^^

for(int i=0;i

return 0;

}

14.7 Lab 4 - File I/O File 1/0 Open a text file and read it. The file would contain integers in each line (total number of integers not exceeding 100). Read all the integers into an integer array. Sort the array in ascending order and then display the integers in a line with space between them. Bubble Sort function is given and does not need to be changed. Sample input file would contain: 22 284 99 Input is: input.txt Output should contain: 34 6 12 22 45 56 94 99 284

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

LO4 Provide an overview of four challenges facing HR today.

Answered: 1 week ago