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

computer programming I don\'t know why but my program is not running; /* Author:

ID: 3684898 • Letter: C

Question

computer programming I don't know why but my program is not running; /* Author: Osaretin Osemwenkha Compiler: Visual Studio Express 2013 for Windows Desktop Date: 3/24/2016 Purpose of program: The program initializes a function initialization by repeatedly calling the rand() a swap function is then use to swap the int contents of two memory locations. Then a sorting function is use to implement a modified version of the initialization function The program prompts the user to input the value to search for and it prints out the result of the search Program ends with system ("pause") which displays "Press any key to continue ..." Note: system ("pause") works only on Windows */ #define _CRT_SECURE_NO_WARNINGS // Needed to avoid error message when using scanf #include #include //function prototype void initiaization(int val[], int size); //initializes the val array void swap(int **, int **);// Swaps the int contents of two memory locations void modifiedSort(int*[], int); //This function should implement a modified version of the above Bubble Sort void display(int[], int);//displays output void displayPointedTo(int*[], int);//displays output int binarySearch(int Val[], int Ind[], int key, int min, int max);//Binary search int main() { int i; //declares i and key int index; //declares index //create the Val array int Val[100]; //call the function to initialize the Val array initiaization(Val, 100); //create the Ind array initialize the Ind array int *point; for (i = 0; i<100; i++) { *(point+i) = i; //initializes Ind[i] }//end for loop //displays “Now displaying data in the original order” printf("Now displaying data in the original order "); //call the display function display(Val, 100); modifiedSort(point, 100); //display “Now displaying data in sorted order” printf(" Now displaying data in sorted order "); //call the display function displayPointedTo(point, 100); //display "Now displaying data in the original order" printf(" Now displaying data in the original order "); //call the display function display(Val, 100); system("pause"); return 0; }//end main //Function definition void initiaization(int Val[], int size) { int i; //declares i size = 100; //initializes size to 100 //For loop to use to initialize the value of each index for (i = 0; i= 1; i--) { //inner for loop continue to iterate till j is less than or equal to i -1 for (j = 0; j <= i - 1; j++) { if (*Point[i] > *Point[j + 1]) { //calls the swap function swap(Point[j], Point[j + 1]); }//end if expression }//end for loop }//end for loop }//end function //Function definition void display(int arr[], int size) { int i; //holds i int count = 1; //declares and initializes count to 1 for (i = 0; i

Explanation / Answer

#define _CRT_SECURE_NO_WARNINGS // Needed to avoid error message when using scanf
#include <stdio.h>
#include <stdlib.h>

//function prototype
void initiaization(int val[], int size); //initializes the val array
void swap(int *, int *);// Swaps the int contents of two memory locations
void modifiedSort(int [], int); //This function should implement a modified version of the above Bubble Sort
void display(int[], int);//displays output
void displayPointedTo(int [], int);//displays output
int binarySearch(int Val[], int Ind[], int key, int min, int max);//Binary search

int main()
{
   //int i; //declares i and key

   //create the Val array
   int Val[100];

   //call the function to initialize the Val array
   initiaization(Val, 100);

   //create the Ind array initialize the Ind array
//int *point = Val;


   //displays “Now displaying data in the original order”
   printf("Now displaying data in the original order ");

   //call the display function
   display(Val, 100);

   modifiedSort(Val, 100);

   //display “Now displaying data in sorted order”
   printf(" Now displaying data in sorted order ");

   //call the display function
   displayPointedTo(Val, 100);

   //display "Now displaying data in the original order"
   printf(" Now displaying data in the original order ");

   //call the display function
   display(Val, 100);

   system("pause");
   return 0;
}//end main

//Function definition
void initiaization(int Val[], int size)
{
   int i; //declares i
   size = 100; //initializes size to 100

   //For loop to use to initialize the value of each index
   for (i = 0; i<size; i++)
   {
       Val[i] = rand() % 1000;
   }//end for loop
}//end function

//Function definition
void swap(int *x, int *y)
{
   int temp;//holds temp
   temp = *x; //initializes temp to *x
   *x = *y; //swaps the contents pointed by the 2 pointers
   *y = temp; //initializes temp to *y
}//end function

//function definition

void modifiedSort(int Point[], int size)
{
   int i, j;//declares i and j

   //outer forloop continue till iterate till i Is greater than or equal to 1
   for (i = size - 1; i >= 1; i--)
   {
       //inner for loop continue to iterate till j is less than or equal to i -1
       for (j = 0; j <= i - 1; j++)
       {
           if (Point[i] > Point[j + 1])
           {
               //calls the swap function
               swap(&Point[j],&Point[j + 1]);
           }//end if expression
       }//end for loop
   }//end for loop
}//end function

//Function definition
void display(int arr[], int size)
{
   int i; //holds i
   int count = 1; //declares and initializes count to 1
   for (i = 0; i<size; i++)
   {
       //Prints output
       printf("%6d", arr[i]);
       count++;//postfix incrementation of count

       //If count is 11 a new line is printed
       if (count == 11)
       {
           printf(" ");
           count = 1;//initializes count to 1
       }//end of if statement
   }//end of for loop
}//end of function

//Function definition
void displayPointedTo(int Point[], int size)
{
   int i; //declares i
   int count = 1; //initializes count to 1

   //for loops which continues to iterate till i is less than size
   for (i = 0; i<size; i++)
   {
       //prints the value of Val[Ind[i]]
       printf("%6d", Point[i]);
       count++;//increments count

       //If count is 11 a new line is printed
       if (count == 11)
       {
           printf(" ");
           count = 1;//initializes count to 1
       }//end if statement
   }//end for loop
}//end function