Question

Write a C Language Program that will ask the user how many elements the maxminarray will have. Read the elements from user

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

Hey,Hey,Hey!!!

Fasten your seat-belt!!!

I like to explain and express things in such a manner so that everybody can easily understand.

So, let’s dive deep into our solution.

Here is the Program Code:-

1 #include<stdio.h> int main() { int n; printf(Input number of elements of the array :); scanf(%d, &n); // take number of

OUTPUT:-

: Input number of elements of the array : 6 Input 6 elements for the maxminarray : element [0] : 23 element [1]: 56 element [

If you need the Code, here it is:-

#include<stdio.h>

int main() {
   int n;
   printf("Input number of elements of the array :");
   scanf("%d", &n); // take number of elements of array as input
   int maxminarray[n];
   printf("Input %d elements for the maxminarray :", n);
   printf("\n");
   for (int i = 0; i < n; i++) {
       printf("element [%d]: ", i);
       scanf("%d", &maxminarray[i]); // reading the elements from the user and filling the maxminarray with it
   }

   int max = maxminarray[0]; // Initialize maximum element
   int min = maxminarray[0]; // Initialize minimum element

   // Traverse array elements from second and compare every element with current max and current min
   for (int i = 1; i < n; i++)
   {
       if (max < maxminarray[i]) {
           max = maxminarray[i];
       }
       if (min > maxminarray[i]) {
           min = maxminarray[i];
       }
   }
   printf("The Maximum element is : %d", max); // printing the maximum element
   printf("\nThe Minimum element is : %d", min); // printing the minimum element
   return 0;
}

Please refer to the screenshot of the code to understand the indentation of the code.

VOILAA!!! We did it.

Please give it a thumbs up if you liked the answer.

> Hi! do you have a program code for this pls i need help,
Get the max and min number from the inputted array elements using c language



Input: 45 56 13 24 75 42 33



Expected Outcome:

Array Elements are: 45 56 13 24 75 42 33

Maximum number is: 75

Minimum number is: 13

Loki Poki Mon, Feb 21, 2022 2:41 PM

Add a comment
Know the answer?
Add Answer to:
Write a C Language Program that will ask the user how many elements the "maxminarray" will...
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
  • in C language Write a program to find the element of an array, which occurs maximum...

    in C language Write a program to find the element of an array, which occurs maximum number of times and its count. The program should accept the array elements as input from the user and print out the most occurring element along with its count. Hint: array size is 5. For example: Enter array elements (array size 5): 22321 Output: Max occurring element: 2. count: 3

  • 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...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Using Matlab Write a program which will: a. Accept two numbers from the user m and...

    Using Matlab Write a program which will: a. Accept two numbers from the user m and n b. Define an array with the dimensions a(n,m) and fill it with random numbers in the range of -100 to 100 inclusive. c. Provide the user the following menu from which he can select: 1. Sum of all elements in the array. Print the result. 2. Sum of the element in a row that he’ll specify. Print the result. 3. Sum of the...

  • Write a Program in C language for: 1. Create a C program to read 7 integers...

    Write a Program in C language for: 1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry...

  • In C language Write a program that includes a function search() that finds the index of...

    In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • (C programing, Not C++) Write a program in C that asks the user to input 10...

    (C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • In C++ Sorted List of User Entered Numbers 2. Write a program that reads in a...

    In C++ Sorted List of User Entered Numbers 2. Write a program that reads in a list of integers into a vector with base type int. Provide the facility to read this vector from an input file. Make sure to ask the user for a filename. The output is a two-column list. The first column is a list of the distinct vector elements. The second column is the count of the number of occurrences for each element. The list should...

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