C code blocks Write the complete function that receives a pointer to a single floating point number as an argument and returns that number after subtracting 100 from it.  Define your function in the same way as the given function prototype.    Take a look at the "For example" below to see how the function is used in the main function and the expected result.  (For interest sake, note that this is a pass-by-reference function call.)   #include  #include void subtractFunc(float *a);int main(){    float num = 357.900;     subtractFunc(&num);     printf("%.3f", num);    return 0; } //Your answer starts here  For example: Test Result float num = 357.900; subtractFunc(&num); printf("%.3f", num); 257.900

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C code blocks

Write the complete function that receives a pointer to a single floating point number as an argument and returns that number after subtracting 100 from it. 

Define your function in the same way as the given function prototype. 

 

Take a look at the "For example" below to see how the function is used in the main function and the expected result. 

(For interest sake, note that this is a pass-by-reference function call.)

 

#include <stdio.h>
#include <stdlib.h>void subtractFunc(float *a);int main(){    float num = 357.900;
    subtractFunc(&num);
    printf("%.3f", num);    return 0;
}

//Your answer starts here 


For example:

Test Result
float num = 357.900; subtractFunc(&num); printf("%.3f", num); 257.900

 

Expert Solution
Step 1

#include <stdio.h>
#include <stdlib.h>

float subtractFunc(float *a);   // Declaring float function for subtracting value and returning float value

int main()
{   float num = 357.900, sub;   // Declaring sub variable to store value returned by function
    
    sub=subtractFunc(&num); // Passing reference of actual value
    
    printf("%.3f", sub);    // Printing value after subtraction
    
    return 0;
}
float subtractFunc(float *a)    
{   float sub;  // Variable to store value 
    
    sub = *a - 100; // Pointer variable have actual value and subtracting 100 
    
    return (sub);   // return float value 
}

 

I have done some sort of changes in the code to get the correct output. Like void replace to float for getting float value after subtraction.  

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education