Question

1. Write a program that prints the minimum value and the maximum value of a given array. For example array a is: int al 10] 1

C programming language

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>    
  
int main() {
        int a[10], n, i;
        int x[] = { 12, 2, 0, 54, 62, 42, 31, 22, 87, 35 };
        int marks[] = { 12, 2, 0, 54, 62, 42, 31, 22, 87, 35 };
        int passed = 0;
                                        //Maximum Minimum
        int min, max;
        min = max = x[0];
        for (i = 0; i < 10; i++) {
                if (x[i] < min)
                        min = x[i];
                if (x[i] > max)
                        max = x[i];
        }
        for (i = 0; i < 10; i++) {
                printf("%d  ", x[i]);
        }
        printf("\nMinimum: %d, Maximum: %d\n", min, max);
                                        //Base 10 to base 2
        printf("Enter the number to convert: ");
        scanf("%d", &n);
        for (i = 0;n>0;i++)
        {
                a[i] = n % 2;                   //Take the remainder after division by 2
                n = n / 2;                              //Divide the number by 2
        }                                                       //Loop until the number is greater than 2
        printf("\nBinary of Given Number is=");
        for (i = i - 1;i >= 0;i--){
                printf("%d", a[i]);
        }
        for (i = 0; i < 10; i++) {
                if (marks[i] >=30)
                        passed++;               
        }
        printf("\nMarks: ");
        for (i = 0; i < 10; i++) {
                printf("%d  ", marks[i]);
        }
        printf("\nPass rate: %f", (passed / 10.0)*100.0);
        getch();
        return 0;
}

CAUsers\VIBHAnDocumentslVisual Studio 2015\ProjectsChegg\DebugChegg.exe 12 2 0 54 62 42 31 22 87 35 Minimum: 0, Maximum: 87 E

Add a comment
Know the answer?
Add Answer to:
C programming language 1. Write a program that prints the minimum value and the maximum value...
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
  • Programming language is C++. 9. Write a program that reads digits and composes them into integers....

    Programming language is C++. 9. Write a program that reads digits and composes them into integers. For example, 123 is read as the characters 1, 2, and 3. The program should output 123 is 1 hundred and 2 tens and 3 ones. The number should be output as an int value Handle numbers with one, two, three, or four digits. Hint: To get the integer value 5 from the character '5' subtract '0' that is, '5'-'0'

  • Answer should be in C programming language Write a program that will create an array of...

    Answer should be in C programming language Write a program that will create an array of 10 floating point numbers and take input 10 floats from keyboard. The program will print the position (index) of the maximum and minimum number among them

  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • C programming! Write a program that reads integers until 0 and prints the sum of values...

    C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...

  • Write a program in C++ language that finds the largest number in an array of positive...

    Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...

  • write in c programming Write a C program that reads in up to 10 numbers into...

    write in c programming Write a C program that reads in up to 10 numbers into an array. The program should count the number of duplicate elements within that array and print the result. Example test data and expected output is given below Test Data: [2,1,1,2,1,3, 4] Duplicates:

  • Consider the following program that reads a number of nonnegative integers into an array and prints...

    Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array.   Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...

  • Programming in C: Write a program that accepts an integer and two floating-point values and prints...

    Programming in C: Write a program that accepts an integer and two floating-point values and prints the sum of these values. Example: Input:12,13.14,6.7; Output:31.84. Use formatted I/O

  • Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive...

    Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive integers). • Prompts the user for a starting number: say 'x' • Prompts the user for an ending number: say 'y' • Prints out the multiplication table of 'x' up to the number 'y' SPECIFIC REQUIREMENTS 1. You must use the following method to load the array: public static void loadArray(int table[][], int x, int y) 2. You must use the following method to...

  • Write a program to reverse an integer number by using a function called reverse. The program...

    Write a program to reverse an integer number by using a function called reverse. The program reads in an integer number and prints its reverse order. Note that the function receives the number via a pointer, and uses the pointer to write the reverse number on the main function. The function MUST be used AS IS: void reverse(int *n) Language in C Bonus Problem: Number Reverser reverse c Write a program to reverse an integer number by using a function...

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
ADVERTISEMENT