Question

Using C Write a function that takes two ints and returns the minimum (smallest) of those...

Using C

Write a function that takes two ints and returns the minimum (smallest) of those two ints. Include a function prototype. In main, call the function with two int inputs of your choice and print the returned value to the output window. The function should not print, just return the smallest number (int). If the numbers are the same, the minimum is just the number.

Please use notes to explain, thanks!

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

#include <stdio.h>

int minimum(int n1, int n2){
   if(n1<n2){
       return n1;
   }
   else{
       return n2;
   }
}

void main()
{
   printf("minimum(2,3) = %d\n",minimum(2,3));
   printf("minimum(3,2) = %d\n",minimum(3,2));
}

Add a comment
Know the answer?
Add Answer to:
Using C Write a function that takes two ints and returns the minimum (smallest) of those...
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 function that takes two ints and returns the average (float) of those two ints....

    Write a function that takes two ints and returns the average (float) of those two ints. Include a function prototype. In main, call the function with two int inputs of your choice and print the returned value to the output window. The function should not print, just make the calculation an return the average. C language not C++

  • Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The...

    Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8) double num1 = 1.5; double num2 = 2.5; char choice; double result;...

  • Write a method that takes an array of ints and that returns true if there are...

    Write a method that takes an array of ints and that returns true if there are more odd numbers than even numbers. However, as for a casino, 0 is not counted as an odd or an even number. If the array is empty or contains only 0's the method should return false.

  • Implement the function odd_total (xs) that takes a list of list of ints xs and returns...

    Implement the function odd_total (xs) that takes a list of list of ints xs and returns the sum of the odd numbers but skips the numbers on the first row and the last column of xs. You're not allowed to modify xs. You can't use any built-in function or method except int, str, range and len. Example: odd_total ([[1,2,3],[4,5,6], [7,8,9]]) - - > 12

  • In C Write a couple of functions to process arrays. Note that from the description of...

    In C Write a couple of functions to process arrays. Note that from the description of the function you have to identify what would be the return type and what would be part of the parameter. display(): The function takes an int array and it’s size and prints the data in the array. sumArray(): It takes an int array and size, and returns the sum of the elements of the array. findMax(): It takes an int array and size, and...

  • C++ write a function named subtract that takes two integers as parameters and returns the result...

    C++ write a function named subtract that takes two integers as parameters and returns the result of subtracting the second number from the first. i.e. int1 - int2 Change subtract to have default arguments for its two parameters. Pick whatever non-zero numbers you would like. Write a prototype for subtract before main so the program runs without error. I cant figure out the part where you pass no parameters, I've tried to set defailt values for the parameters but it...

  • write a c++ function, do not #include anything, that returns the max of 6 ints int...

    write a c++ function, do not #include anything, that returns the max of 6 ints int max(int, int, int, int, int, int); allowed to use built in max(int, int) function.

  • Write a function to find the smallest odd number in a list. The function takes a...

    Write a function to find the smallest odd number in a list. The function takes a list of numbers (each number is greater than or equal to 0) as an input. The function outputs a tuple, where the first number in the tuple is the smallest odd number and the second number in the tuple is the number of occurrences of that number. For example, if the input is [1, 4, 7, 3, 5, 2, 1, 3, 6] then the...

  • *Please write in code in C* First, write a function called prime_check(int x) that takes an...

    *Please write in code in C* First, write a function called prime_check(int x) that takes an integer number as an input then return 1 if it is a prime number nd returns 0 if it is a composite number Then, Write a program that prompt the user to input two numbers: Print the multiplication of these two numbers if both of them are prime. Or Print " Sorry at least one of your number is composite" if otherwise

  • Write a C++ program that contains a function called swapNums. This function takes two integer parameters,...

    Write a C++ program that contains a function called swapNums. This function takes two integer parameters, swaps them in memory, and outputs the results (there is nothing to return). In main, ask the user to enter two different numbers, output them as entered (step 1), call the function swapNums() which will output the numbers swapped (step 2), and then output the values again in main (step 3). You should have three sets of output. Sample run (10 and 5 were...

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