Question

Write a C program by completing the following skeleton program. /* file minmax.c  **************************************** *   ...

Write a C program by completing the following skeleton program.

/* file minmax.c  ****************************************


*        a C program skeleton for the problem


*        Find the minimum and maximum values in an array



**********************************************************/


#include <stdio.h>

/* DATA segment: Global variables */


#define SIZE 10


        int arr[SIZE] = { -5, 0xffffface, 0x31, 52, 054, /* base 8 */


                        0, -201, 12, 0xffffff00, -1 } ;

int main ()


{  /* declare variables here */


        int mymin, mymax;               /* use these */

/* Place your solution between the cut lines */


/*------------------ start cut --------------------------*/


/* Student ------             */


/* declare ADDITIONAL variables here, AFTER "start cut" */


/*----------------------- end cut -----------------------*/


    printf ("The minumum = %d and the %s = %d\n", mymin,"maximum", mymax);

    return 0;    /* 0 tells operating system "Normal termination" */


}   /* end main */


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

SNAPSHOT OF CODE :

CODE :

#include <stdio.h>

/* DATA segment: Global variables */

#define SIZE 10

        int arr[SIZE] = { -5, 0xffffface, 0x31, 52, 054, /* base 8 */

                        0, -201, 12, 0xffffff00, -1 } ;

int main ()

{  /* declare variables here */

        int mymin, mymax;               /* use these */

/* Place your solution between the cut lines */

/*------------------ start cut --------------------------*/

/* Student ------             */

/* declare ADDITIONAL variables here, AFTER "start cut" */

int i=0;

mymin=mymax=arr[0];

for ( i = 1; i < SIZE; i++)

{

    /* code */

     if(mymin>arr[i])

          mymin=arr[i];   

           if(mymax<arr[i])

               mymax=arr[i];   

}

/*----------------------- end cut -----------------------*/

    printf ("The minumum = %d and the %s = %d\n", mymin,"maximum", mymax);

    return 0;    /* 0 tells operating system "Normal termination" */

}   /* end main */

IMPORTANT POINTS :

  • Because The Array Contains Mixed Numbers Like Decimal, Octal, and HexaDecimal Numbers, But As The Array is Of Integer Type So All The Numbers Are Therefore Converted Into Integers
  • So The Array Internally After Conversion Looks Like:
  • int arr[10] { (int) (-5), (int) (-1330), (int) (49), (int) (52), (int) (44), (int) (0), (int) (-201), (int) (12), (int) (-256), (int) (-1) }

OUTPUT :

// Feel Free To Ask Any Question !!!

// Keep Then Happy Chegging !!!

// Thank You !!!

Add a comment
Know the answer?
Add Answer to:
Write a C program by completing the following skeleton program. /* file minmax.c  **************************************** *   ...
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
  • How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++...

    How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each...

    c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...

  • Step 4: Write a Sum Function Since we can write, compile and run simple c files,...

    Step 4: Write a Sum Function Since we can write, compile and run simple c files, lets add a bit to make a program that will sum an entire array of integers. To do this we are going to simply overwrite the main.c file to include the new function. The sum function below is not complete and must be finished before the program will execute properly. %%file main.c #include <stdio.h> int sum(int array[], int arrayLength) {     int i =...

  • I need some with this program, please look at the changes I need closely. Its running...

    I need some with this program, please look at the changes I need closely. Its running correctly, but I need to do a few adjustments here is the list of changes I need: 1. All of the integers on a single line, sorted in ascending order. 2. The median value of the sorted array on a single line 3. The average of the sorted array on a single line Here is the program: #include<stdio.h> #include<stdlib.h> /* This places the Adds...

  • 9. The purpose of the following program is to generate 10 random integers, store them in...

    9. The purpose of the following program is to generate 10 random integers, store them in an array, and then store in the freq frequency array, the number of occurrences of each number from 0 to 9. Can you find any errors in the program? If yes, correct them. #include <stdio.h> #include <stdlib.h> #include <time.h> #define SIZE 10 int main(void) int i, num, arr[SIZE], freq[SIZE]; srand (time (NULL)); arr[1] rand(); SIZE; for(i i 〈 i++) num arr[i]; freq[num]++; printf("InNumber occurrences...

  • A)Correct this code and explain what was corrected // C code - For Loop / Array...

    A)Correct this code and explain what was corrected // C code - For Loop / Array Population // This program will populate integers into an array, and then display those integers. // Developer: Johnson, William CMIS102 // Date: Mar 4, 2020 // Global constants #define INTLIMIT 10 #include <stdio.h> // This function will handle printing my name, class/section number, and the date void printStudentData() { char fullName[19] = "William J. Johnson"; char classNumber[9] = "CMIS 102"; char sectionNumber[5] = "4020";...

  • Use two files for this lab: your C program file, and a separate text file containing...

    Use two files for this lab: your C program file, and a separate text file containing the integer data values to process. Use a while loop to read one data value each time until all values in the file have been read, and you should design your program so that your while loop can handle a file of any size. You may assume that there are no more than 50 data values in the file. Save each value read from...

  • Q2. Consider the following C++ program that declares, allocates and fills in a1D array with random...

    Q2. Consider the following C++ program that declares, allocates and fills in a1D array with random numbers between 0 and 100. The array is sent to a function that finds the indices of all items > 50. A new array is created and the indices are stored inside it. The size of the new arrays MUST BE the same as the number of items > 50. The function returns the new array which is then printed out by main. Here...

  • C program-- the output is not right please help me to correct it. #include <stdio.h> int...

    C program-- the output is not right please help me to correct it. #include <stdio.h> int main() { int arr[100]; int i,j,n,p,value,temp; printf("Enter the number of elements in the array: \n "); scanf("%d",&n); printf("Enter %d elements in the array: \n",n); for(i=0;i<n;i++) { printf("\nelement %d: ",i); scanf("\n%d",&arr[i]); } printf("\nEnter the value to be inserted: \n "); scanf("\n%d",&value); printf("The exist array is: \n"); for(i=0;i<n;i++) { printf("%d",arr[i]); } p=i; for(i=0;i<n;i++) if(value<arr[i] ) { p = i; break; } arr[p]=value; printf("\n"); for (i =...

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