Write functions that implement the following functionalities. Use the specificat
ID: 3754948 • Letter: W
Question
Write functions that implement the following functionalities. Use the specifications provided.
Write functions that implement the following functionalities. Use specifications provided Functionality 1. Print addition of two numbers declared inside the function 2. Add two numbers provided as function inputs and printaddTwoNum output 3. Add two numbers provided as function inputs and return returnAddTwoNum a,b (floats) sum (float) output Function Name addStart Input None Return None a,b (floats)NoneExplanation / Answer
#include<iostream>
using namespace std;
//since you haven't specified which languge
//i have provided codes for c++ and java written with basic syntax
//these will help you with logic
//i hope you get it
//other wise comment your required language, i will provide code for that
void addStart()
{
//declarint variables
float a=5,b=3;
//finding sum and displaying output
cout<<"The sum of "<<a<<" and "<<b<<" is :"<<(a+b)<<endl;
}
void addTwoNumbers(float a,float b)
{//provinding a and b as function inputs
//finding sum and displaying output
cout<<"The sum of "<<a<<" and "<<b<<" is :"<<(a+b)<<endl;
}
float returnAddTwoNumbers(float a,float b)
{
//finding sum and returning
return (a+b);
}
int main()
{
//testing methods
addStart();
addTwoNumbers(5,4);
cout<<"The sum of "<<8<<" and "<<3<<" is :"<<returnAddTwoNumbers(8,3);
}
output:
The sum of 5 and 3 is :8
The sum of 5 and 4 is :9
The sum of 8 and 3 is :11
Process exited normally.
Press any key to continue . . .
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Vamsi
*/
public class Sum1 {
static void addStart()
{
//declarint variables
float a=5,b=3;
//finding sum and displaying output
System.out.println("The sum of "+a+" and "+b+" is :"+(a+b));
}
static void addTwoNumbers(float a,float b)
{//provinding a and b as function inputs
//finding sum and displaying output
System.out.println("The sum of "+a+" and "+b+" is :"+(a+b));
}
static float returnAddTwoNumbers(float a,float b)
{
//finding sum and returning
return (a+b);
}
public static void main(String argv[])
{
//testing methods
addStart();
addTwoNumbers(5,4);
System.out.println("The sum of "+8+" and "+3+" is :"+returnAddTwoNumbers(8,3));
}
}
output:
run:
The sum of 5.0 and 3.0 is :8.0
The sum of 5.0 and 4.0 is :9.0
The sum of 8 and 3 is :11.0
BUILD SUCCESSFUL (total time: 0 seconds)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.