Question

Write a program which will take a list of integer

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

Answer: #include<stdio.h> int maxmin (int n); //method definition void main() //variable declaration int n; printf (Enter thfor (i-0:i<nii++) scan f (%d, &arr [1] ) ; //display the array printf ( Innumbers in the array are:) for ( 1-0 ; i<nii++)btti //display the max and min number printf(\nMaximum number in the array is: printf(\nMinimum number in the array is: %d

Copyable code:

#include<stdio.h>

int maxmin(int n);

//method definition

void main()

{

    //variable declaration

    int n;

    printf("Enter the number of elements: ");

    scanf("%d",&n);

    //function calling

    maxmin(n);

}

//function definition

int maxmin(int n)

{

    //variable declaration

    int arr[10],i,max,min;

    int *b;

    //get the array of numbers

    printf("\nEnter %d numbers in an array: ",n);

    for(i=0;i<n;i++)

    scanf("%d",&arr[i]);

    //display the array

    printf("\nnumbers in the array are:");

    for(i=0;i<n;i++)

    printf("%2d",arr[i]);

    b=&arr[0];

    max=arr[0];

    min=arr[0];

    //finding the maximum number

    for(i=0;i<n;i++)

    {

        if(max<= *b)

        {

            max=*b;

        }

        //finding the minimum number

        else if(min>=*b)

        {

            min= *b;

        }

        b++;

    }

    //display the max and min number

    printf("\nMaximum number in the array is: %d",max);

    printf("\nMinimum number in the array is: %d\n",min);

}

Add a comment
Know the answer?
Add Answer to:
Write a program which will take a list of integer number from the user as input...
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
  • Write a java program that will print if n numbers that the user will input are...

    Write a java program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times asking for an integer...

  • IN JAVA 1. Create a program that prompts the user for an integer and then displays...

    IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...

  • Write a program in C that will convert all 12 months' average temperature from Celsius to...

    Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...

  • Write a program that asks the user to input a 4-digit integer and then prints the...

    Write a program that asks the user to input a 4-digit integer and then prints the integer in reverse. Your program needs to implement a function reverse that will take in as input the 4-digit number and print it out in reverse. Your code will consist of two files: main.s and reverse.s. Main.s will ask for the user input number and call the function reverse. For ARM/Data Structure needs to be able to run on Pi Reverse.s will take in...

  • Write a program that takes a list of integer numbers from a user and creates a...

    Write a program that takes a list of integer numbers from a user and creates a new sorted in ascending order list. As output you need to print original list and sorted one. use list and while python

  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value...

    Ask user to enter three numbers (a,b,c). Write a program (c++) that will print the value to the following equations: a. maximum value of one of these equations (functions separated by commas) (a, a+b, a-c) + maximum of (b, 2b-c, b+2a) b. maximum value of (3, c+3a, 0) + minimum of (ab-2, 3c, ac) Define functions max and min which will accept 3 numbers as arguments and return the mix and min of them correspondingly. Use these functions in order...

  • Write a Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

  • 2. Write a program that reads N integer numbers of array from the user and then...

    2. Write a program that reads N integer numbers of array from the user and then displays the sum, max number and the numbers of the array use four subroutines ( Read_Array(), Calculate_Sum(), Find_Max() and Display_Array()). Here is sample output Please enter number of elements: 4 Please enter the required numbers: 50 100 150 20 The entered numbers are: 50 100 150 20 Sum is : 320 Max is 150 by Mpsi ,sum and max to call subroutine and retrieve...

  • Write a program that can: 1. Insert twenty random numbers into a linked list. The numbers...

    Write a program that can: 1. Insert twenty random numbers into a linked list. The numbers should be within a range (E.g., 1 to 7). The user should be prompted to enter the minimum number and maximum number of the range. Each number should be inserted at the end of the list. Section 7.8 of the textbook covers the random number generator. Examples of how to use the random number generator are in Fig 7.6 and 7.7. Here is a...

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