I need help figuring out how to create a header file that will work with the mai
ID: 3858340 • Letter: I
Question
I need help figuring out how to create a header file that will work with the main file in a c. compiler program. Im using codeblocks. Screenshots greatly appreciated.
I need help with a code that can create functions for different types of multiplications, and using a header file to call the variables for the function.
This is a screenshot of the project im working on, any help to get started, or to finish would help. Thank you!
Details Types e bigInt Any other auxili Functions: .ClassicalMult (bigInt A, bigInt B, int In header file base . Classical multiplication Both recursive and non- recursive versions are accepted. . karatsubaMult (bigInt A, biglnt B, intI . In header file base) Karatsuba Multiplication ToomMult (bigInt A, bigInt B, int base) In header file Toom-Cook 3 Multiplication » In header file * CompareAlgorithms (char firstalgorithm, char firstalgorithm, intComparing two multiplication size) algorithms using size-digit random numbers. . Return values The execution time for each algorithm The subtraction of the results of two algorithms “c": Classical “k": Karatsuba "t” : Toom-CookExplanation / Answer
How to create a header file that will work with the main file in a c.
Step1 : Type this Code
int add(int a,int b)
{
return(a+b);
int add(int a,int b)
{
return(a+b);
}
In this Code write only function definition as you write in General C Program
Step 2 : Save Code
Save Above Code with [.h ] Extension .
Let name of our header file be myhead [ myhead.h ]
Compile Code if required.
Step 3 : Write Main Program
#include<stdio.h>
#include"myhead.h"
void main() {
int num1 = 10, num2 = 10, num3;
num3 = add(num1, num2);
printf("Addition of Two numbers : %d", num3);
}
#include<stdio.h>
#include"myhead.h"
void main() {
int num1 = 10, num2 = 10, num3;
num3 = add(num1, num2);
printf("Addition of Two numbers : %d", num3);
}
Include Our New Header File .
Instead of writing < myhead.h> use this terminology “myhead.h”
All the Functions defined in the myhead.h header file are now ready for use .
Directly call function add(); [ Provide proper parameter and take care of return type ]
Note
While running your program precaution to be taken : Both files [ myhead.h and sample.c ] should be in same folder.
================================================
If you want to add some external header files, then:
1. Go to project->build options.
2. "search directories"
3. "compilers" sub tab.
4. Click add, select the file and you are done.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.