Question

C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a...

C LANGUAGE

Create your own library named cis340yourlastname.

Create a header file named cis340yourlastname.

Write a program that receives two numbers from the user and uses your written library to calculate the reminder after division, the addition, and the subtraction of these two input numbers. (Hint your library should include three functions. Your header file should not contain the code for any of these functions, it should contain only the instructions for how to use the library).

Homework Answers

Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

Make sure you copy below three files (header file, implementation file and test file) into separate files as mentioned. Do not copy everything to a single file.

//cis340yourlastname.h file (change file name as needed)

#ifndef cis340yourlastname_h //change this according to file name

#define cis340yourlastname_h //change this according to file name

//declarations for all three functions needed

//returns the remainder of a/b.

//example usage:

//rem(10,5) will return 0

//rem(5,2) will return 1

int rem(int a, int b);

//adds two integers and return the sum

//example usage:

//add(10,13) will return 23

int add(int a, int b);

//return the result of a-b

//example usage:

//sub(10,13) will return -3

int sub(int a, int b);

#endif

//end of cis340yourlastname.h file

//cis340yourlastname.c file

#include "cis340yourlastname.h"

//defining the body of each method declared in cis340yourlastname.h file

int rem(int a, int b){

                return a % b;

}

int add(int a, int b){

                return a + b;

}

int sub(int a, int b){

                return a - b;

}

//end of cis340yourlastname.c file

//main.c for testing

#include<stdio.h>

#include "cis340yourlastname.h" //including cis340yourlastname header file

int main(){

                int a,b;

                //asking and reading values of two integers

                printf("Enter two integers: ");

                scanf("%d %d",&a,&b);

               

                //displaying remainder, addition and subtraction results

                printf("Remainder after division: %d\n",rem(a,b));

                printf("Addition: %d\n",add(a,b));

                printf("Subtraction: %d\n",sub(a,b));

               

                return 0;

}

//end of main.c

/*OUTPUT*/

Enter two integers: 5 2

Remainder after division: 1

Addition: 7

Subtraction: 3

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a program that generates a file of random numbers, and then prints them in neat...
Create a program that generates a file of random numbers, and then prints them in neat fashion to another file, and also saves to that file the average and standard deviation of those numbers. I) First, you would need to generate a file of random numbers that consists of N random numbers (100 < N < 1000). Each random digit should be a real number (type double) between 0 and 50. This file and its digits would now serve as...
C++ If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap13...
C++ If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Introductory20.cpp. Write a program that displays the appropriate shipping charge based on the region code entered by the user. To be valid, the region code must contain exactly three characters: a letter (either A or B) followed by two numbers. The shipping charge for region A is $25. The shipping charge for region B is $30....
Write a program that reads a file named input.txt and writes a file that contains the...
Write a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. Do not use a copy method that is supplied by Java. Your program must read the file line by line...
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
Code a C file, following these instructions: This lab is about getting the input from a...
Code a C file, following these instructions: This lab is about getting the input from a file. Let’s assume the words are provided in one file, passed as an argument to your program. The names of the files are provided as arguments to your program (i.e., they are copied by the shell in the argv variable), and each file is a text file with lots of words. Open the manual page for open() system call and add to your code...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked onto a linked list. The data structure should have the following fields: a. First Name (firstName) b. Last Name (lastName) c. Employee ID (id) d. Start Year (startYear) e. Starting Salary (startSalary) f. Current Salary (currentSalary) g. next Create a library of functions that operate on this data structure. The source code for the functions should be in lastname_employeerec.c and the function prototypes should...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent Windows32 integrated development environment (IDE)] program into one that inputs two positive integers, and outputs their greatest common divisor, by implementing the following pseudo-code: input num1 and num2 (assume num1 > 0 and num2 > 0) gcd := num1 remainder := num2 repeat numerator := gcd gcd := remainder remainder := numerator % gcd until (remainder == 0) output gcd The following 3 windows...
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
Create a stadium class. The class header file content (.h file) can go in this question,...
Create a stadium class. The class header file content (.h file) can go in this question, the class implementation (.cpp file) can go in the following question, and the main.cpp content can go in the third question. static data members: starting seat number next seat number data members: stadium name name of home team current opponent seats sold (vector of seat numbers) member functions: custom constructor - take input of stadium name default constructor get next seat number (static) change...
Create a program that filters the data in a CSV file of product data based on...
Create a program that filters the data in a CSV file of product data based on some search word and prints the resulting output to a new file. Additionally, the program will print the number of items filtered to stdout. • Your program should take three arguments: an input file to process, an output file to save the results, and a search word. • If the output file already exists or cannot be opened, warn the user by printing "CANNOT...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT