Write a full C program that allows the user to input two dec

Write a full C++ program that allows the user to input two decimal numbers such as 13.2 and 4.56. The main function should pass those two values to a function named difference, which must return the result of subtracting the second parameter from the first parameter. The main function should display the final average on the screen. You can assume that the user will input two valid decimal numbers.

Solution

#include<iostream>
using namespace std;

double difference(double first,double second)
{
return first-second;
}

int main(void) {
   // your code goes here
double first,second;
  
cout << \"Input first number : \";
cin >> first;
  
cout << \"Input second number : \";
cin >> second;
  
double diff = difference(first,second);
cout << \"Difference is : \" << diff;
   return 0;
}

OUTPUT:

Input first number : 13.2

Input second number : 4.56

Difference is : 8.64

Write a full C++ program that allows the user to input two decimal numbers such as 13.2 and 4.56. The main function should pass those two values to a function n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site