Question

Write C program that find maximum and minimum of any numbers. Note: don’t use array, and...

Write C program that find maximum and minimum of any numbers.

Note: don’t use array, and only use switch or while loop or if-statement, because I’m beginner.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include<stdio.h>

#include<limits.h>

int main(){

int min = INT_MAX, max = INT_MIN;

int n, num, i=0;

printf("How many numbers would you like to enter: ");

scanf("%d", &n);

while(i<n){

printf("Enter number: ");

scanf("%d", &num);

if(min>num)

min = num;

if(max<num)

max = num;

i++;

}

printf("Maximum: %d\n", max);

printf("Minimum: %d\n", min);

return 0;

}

nagaraju@nagaraju-Vostro-3550:/Desktop/CHEGG/2019/February/20022019$ gcc max_min.c nagaraju@nagaraju-Vostro-3550:/Desktop/CHE

Add a comment
Know the answer?
Add Answer to:
Write C program that find maximum and minimum of any numbers. Note: don’t use array, and...
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
  • 1- Write a program to read 10 numbers and find the average of these numbers. Use...

    1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...

  • Write a program that performs the following operations on a one dimensional array with 50 unsigned...

    Write a program that performs the following operations on a one dimensional array with 50 unsigned integers. The main program will initialize the array, print the array values to the screen and then call a function that will determine and print the maximum and minimum values. •Declare the array and any other variables. •Use a loop to initialize the array with 50 random integer values between 0 and 99 using the rand() function. (number = rand() % 100;) •Using cout...

  • write program above in C only Write a program to find statistics on some random numbers....

    write program above in C only Write a program to find statistics on some random numbers. Seed the random number generator with time. In a for loop generate 12 random numbers between the values of 2 and 20. Print the numbers. As the numbers are generated, find the following: the number of even numbers (those evenly divisible by 2) e the sum of the even numbers the product of the even numbers the maximum value of all the numbers e

  • C++ Write a program that generates and prints 24 random values using an array and the...

    C++ Write a program that generates and prints 24 random values using an array and the rand () function. Implement an algorithm to find the maximum and a minimum number of random numbers generated. Use the header "#include <ctime>", "#include <cstdlib>" in addition to the usual header: "#include <iostream>"

  • Write a Prolog program to find the maximum, minimum, and range of values in a list...

    Write a Prolog program to find the maximum, minimum, and range of values in a list of numbers. Please also provide the program with output.

  • C programming language 1. Write a program that prints the minimum value and the maximum value...

    C programming language 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] 140,30,20,50,10,80,99.90,85,70;: the minimum value is 10 and the maximum value is 99. Write a program that Converts an Integer from base 10 to base 2. 2. 3. Write a program that reads in ten marks and then calculates the pass rate

  • 1. Write a C code that do the following: Generate array of random integer numbers of...

    1. Write a C code that do the following: Generate array of random integer numbers of size 25 Fill the array with random integers ranging from [1-100] Find the maximum number of the array and its location Find the minimum number of the array and its location Search for a number in the array Print the array Flip the array Sort this array Quit the program when the user choose to exit

  • 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++: Write a program that asks the user for an array of X numbers. Your...

    In C++: Write a program that asks the user for an array of X numbers. Your program moves the largest number all the way to the right, and then shows it to the user. Hint: Use a loop to swap X times, but only swap if the number on the left is bigger than the number on the right. Sample Run: How many numbers would you like to enter? 6 Please enter number 1: 10 Please enter number 2: 8...

  • Write a C++ program that will create an array with a given number of elements. Use...

    Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....

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