Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this, you are to write a C++ program to process randomly generated integers

ID: 3637197 • Letter: F

Question

For this, you are to write a C++ program to process randomly generated integers in an input file. The name of the input file is prog1.d (included below). There are exactly 200 random integers, in the range of 1…10000, in this file.
Your program gets the random integers from stdin and puts them in an array, sorts the integers in the array in ascending order, and then displays the contents of the array on stdout. To sort the contents of the array, the main ( ) routine calls the sort ( ) routine in the STL, and to print out the contents of the array, you need to implement the following subroutine:
• void printArr ( int arr [ ] ): This routine displays the contents of the array arr on stdout, printing exactly 12 numbers on a single line, except perhaps the last line. The sorted numbers need to be properly aligned on the output.

Programming Notes:
• You are not allowed to use any I/O functions from the C library, such as scanf or printf. Instead, use the I/O functions from the C++ library, such as cin or cout.

• Do not forget to include the header file 340.h, by inserting the statement: #include “/home/onyuksel/courses/340/common/340.h” at the top of your source file. Every system file, you might need, is already included in this header file, so you don’t need to include any other files (except yours) in your source file.

• In your program, define all constants, such as the size of the input, which is 200, and the number of integers displayed on a single line, which is12. The best place to put the definitions of constant values is in a header file, such as prog1.h. You can also include the prototypes of all the subroutines in your program in your header file. Since a header file may be included in more than one source file, the statements in a header file must be guarded by the C-preprocessor directives.

• Let arr be an array of integers and N be the size of this array, then the call “sort ( arr, arr + N )” sorts the elements of arr in ascending order.


Input file

9384 887 2778 6916 7794 8336 5387 493 6650 1422 2363 28
8691 60 7764 3927 541 3427 9173 5737 5212 5369 2568 6430
5783 1531 2863 5124 4068 3136 3930 9803 4023 3059 3070 8168
1394 8457 5012 8043 6230 7374 4422 4920 3785 8538 5199 4325
8316 4371 6414 3527 6092 8981 9957 1874 6863 9171 6997 7282
2306 926 7085 6328 337 6506 847 1730 1314 5858 6125 3896
9583 546 8815 3368 5435 365 4044 3751 1088 6809 7277 7179
5789 3585 5404 2652 2755 2400 9933 5061 9677 3369 7740 13
6227 8587 8095 7540 796 571 1435 379 7468 6602 98 2903
3318 493 6653 757 7302 281 4287 9442 3866 9690 8445 6620
8441 4730 8032 8118 8098 5772 4482 676 710 8928 4568 7857
9498 2354 4587 6966 5307 4684 6220 8625 1529 2872 5733 8830
9504 20 8271 3369 9709 6716 6341 8150 7797 724 2619 2246
2847 3452 2922 3556 2380 7489 7765 8229 9842 2351 5194 1501
7035 7765 125 4915 6988 5857 3744 6492 2228 8366 9860 1937
1433 2552 6438 9229 3276 5408 1475 6122 8859 4396 6030 1238
8236 3794 5819 4429 6144 1012 5929 9530



Expected output



13 20 28 60 98 125 281 337 365 379 493 493
541 546 571 676 710 724 757 796 847 887 926 1012
1088 1238 1314 1394 1422 1433 1435 1475 1501 1529 1531 1730
1874 1937 2228 2246 2306 2351 2354 2363 2380 2400 2552 2568
2619 2652 2755 2778 2847 2863 2872 2903 2922 3059 3070 3136
3276 3318 3368 3369 3369 3427 3452 3527 3556 3585 3744 3751
3785 3794 3866 3896 3927 3930 4023 4044 4068 4287 4325 4371
4396 4422 4429 4482 4568 4587 4684 4730 4915 4920 5012 5061
5124 5194 5199 5212 5307 5369 5387 5404 5408 5435 5733 5737
5772 5783 5789 5819 5857 5858 5929 6030 6092 6122 6125 6144
6220 6227 6230 6328 6341 6414 6430 6438 6492 6506 6602 6620
6650 6653 6716 6809 6863 6916 6966 6988 6997 7035 7085 7179
7277 7282 7302 7374 7468 7489 7540 7740 7764 7765 7765 7794
7797 7857 8032 8043 8095 8098 8118 8150 8168 8229 8236 8271
8316 8336 8366 8441 8445 8457 8538 8587 8625 8691 8815 8830
8859 8928 8981 9171 9173 9229 9384 9442 9498 9504 9530 9583
9677 9690 9709 9803 9842 9860 9933 9957

Explanation / Answer

#include #include #include using namespace std; #define N 200 #define NUM 12 void printArr(int arr[]) { for(int i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote