*.H FILE IN C PROGRAM* Write a calculator program that adds and subtracts. Promp
ID: 3682154 • Letter: #
Question
*.H FILE IN C PROGRAM*
Write a calculator program that adds and subtracts. Prompt the user to enter two values and select an operation to perform. Incorporate a program with five modules and functions named as follows:
calc_driver.c - contains the function main() and the user interface
addition.h - contains the prototype for a function named add()
addition.c - contains the function definition for add()
subtraction.h - contains the prototype for a function named subtract()
subtraction.c - contains the function definition for subtract(
Explanation / Answer
Please find the required solution:
calc_driver.c - contains the function main() and the user interface:
#include <stdio.h>
#include "addition.h"
#include "subtraction.h"
#include "addition.c"
#include "subtraction.c"
int main()
{
int a,b;
printf("Calculater for enter 2 numbers");
scanf("%d",&a,&b);
printf("%d",sum(a,b));
printf("%d",sub(a,b));
return 0;
}
addition.h - contains the prototype for a function named add()
int add(int,int);
addition.c - contains the function definition for add()
#include "addition.h"
int add(int op1,int op2)
{
return op1+op2;
}
subtraction.h - contains the prototype for a function named subtract()
int sub(int,int);
subtraction.c - contains the function definition for subtract
#include "subtraction.h"
int sub(int op1,int op2)
{
return op1-op2;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.