C++ program : Two sorted files (File1.txt: XXXXXXXXXXFile2.txt: 2 XXXXXXXXXX13) The C++ program going to check if the file are sorted and merge them to third file (Mergefile.txt: 1 2 3 XXXXXXXXXX...


C++ program : Two sorted files (File1.txt: 1 3 4 6 7 8 11) (File2.txt: 2  3 5 6 7 9 10 11 12 13)


The C++ program going to check if the file are sorted and merge them to third file (Mergefile.txt: 1 2 3  3 4 5 6 6 7 7 8 9 10 11 11 12 13)



Program Plan:


"Main.cpp"



  • Include the requierd header files

  • Declare the necessary function prototype and constants.

  • Define the main() function

  • Under Main function:

  • Get the first file name  from the user

  • Check if the first file is sorted using the function "check()"

  • Get the second file name from the user

  • Check if the second file is sorted using function "check()"

  • Merge the two file using the function "merge()".

  • Print the result in to merge file


"Check.h"



  • Define the template function necessary

  • Define the bool check "Check if the file is sorted"

  • Declare the necessery structure variables

  • Define the necessary function prototype.

  • Loop till the file is not empty

  • Assign the first file value

  • Assign the second and third and forth untill the reusults will show that the file is sorted

  • The function will not read only the first two values and print that file is sorted. It will read a few values untill the results will show that file is really sorted.


"Merge.h"



  • Define the template function necessary

  • Define the merge "Merge the two sorted files"

  • Declare the necessery structure variables

  • Define the necessary function prototype.

  • Include the required header files

  • Assign null pointer to "merge two files"

  • Check if the first file and the second file are not sorted and * return 0;

  • Check if the both are sorted

  • Make the first file to merge file

  • make the second file to merge file

  • Unconditional loop merge the two files

  • Check the first file is not empty and return to the merge file

  • check the second file is not empty and return to the merge file

  • Condition for first file  non empty and second file non empty

  • Make sure the Merge file is sorted

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here