answersLogoWhite

0


Best Answer

#include <iostream>

using std::cin;

using std::cout;

using std::endl;

double minimum(double arg1, double arg2, double arg3);

int main()

{

cout << "Enter first number: ";

double firstNumber = 0.0;

cin >> firstNumber;

cout >> "Enter second number: ";

double secondNumber = 0.0;

cin >> secondNumber;

cout << "Enter third number: ";

double thirdNumber = 0.0;

cin >> thirdNumber;

cout << "\nThe smallest number is " << minimum(firstNumber, secondNumber, thirdNumber) << endl;

return 0;

}

//All three arguments have to be different

double minimum(double arg1, double arg2, double arg3)

{

double min = arg1;

if (arg 1 > arg2)

{

min = arg2;

}

else if (arg1 > arg3)

{

min = arg3;

}

return min;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How a program in c plus plus plus plus using function that returns the smallest of three floating-point numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a Shell program to find the smallest number from a set of numbers?

k


C program to find only smallest numbers in the given list?

int findSmallest(int *list, int listsize) { int i; int smallest = list[0]; for(i = 1; i &lt; listsize; i++) { if(list[i] &lt; smallest) smallest = list[i]; } return smallest; }


How do you write a program that will call a function to multiply 4 numbers and return the answer to main program?

In Windows, use notepad.exe; in linux, use program xedit.


2 Write a program to print a following program?

USING STRING LITERAL VALUES TO ADD 2 NUMBERS If you just want to show the outcome of two numbers you have: PRINT 4 + 5 This will print '9' the answer to 4 + 5. If you want to show the addition: PRINT "4 + 5 = "; 4 + 5 This will show the question and then calculate the answer. If you want the user to input numbers to add, use variables and then add them the same way. ====== COLLECTING USER INPUT FROM THE KEYBOARD/USING NUMERIC VARIABLES In the following example, the end user can get to interact with the program by typing in their numbers at the keyboard; then, pressing the [Enter] key. CLS PRINT "PROGRAM: Add 2 numbers" PRINT INPUT "Enter the 1st number: ", number1 INPUT "Enter the 2nd number: ", number2 PRINT sumTotal=number1+number2 PRINT "The sum total is: "; sumTotal PRINT INPUT "Again, Y/N"; yesNo$ IF UCASE$(LEFT$(yesNo$,1))="Y" THEN RUN END ====== CREATE FUNCTION/THEN, MAKE A FUNCTION CALL TO ADD 2 NUMBERS Another way to write this program is to create a function/then, make a function call... '*** PROGRAM: Add 2 numbers... '*** Variable declaration list... number1=7 '...initialise numeric variable 1 number2=3 '...initialise numeric variable 2 '*** Main program... CLS '...(CL)ear the (S)creen PRINT add(number1,number2) '...make function call/passing in 2 numbers to add END '...END of program/halt program code execution '*** Function(s)... FUNCTION add(num1,num2) '...this line marks the start of the Function add=num1+num2 '...this line returns the sum total of the 2 numbers END FUNCTION '...this line marks the end of the Function


Write a program to swap two numbers using function?

swap (int *a, int *b) { *a ^= *b; *b ^= *a; *a ^= *b; }


Which function is supported by an application program?

which function is support by an application program


What is a token in the context of a C program?

smallest individual units of a program


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


In java What is a smallest individual unit in a program?

token


What is the smallest addressable memory unit in C?

program