Correct the following declaration of function f of type floa


Correct the following declaration of function f of type float with parameters a and b of type int: float f (int a, b);

Solution

Given declaration: float f (int a, b)

1.    Function declaration syntax: ReturnType functionName(dataType Parameter1, dataType Parameter2, dataType Parameter3, ...)

2.    Each and every parameter of function should precede data type. For eg: int p, double q etc...

3. Correct declaration of function f:

   float f(int a, int b)
  
   Function Name: f
  
   Return Type: float
  
   Parameters:
               (i) a of data type int
               (ii)   b of data type int
  
  
4. Sample function can be as follows:

   float retValue = f(10, 20);
  
   Values 10 and 20 are substituted for variables a & b respectively.
  
   Return value of function f is stored in variable retValue.

 Correct the following declaration of function f of type float with parameters a and b of type int: float f (int a, b);SolutionGiven declaration: float f (int a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site