Initial commit
This commit is contained in:
10
kapitel15/jbmath/jbmath.c
Normal file
10
kapitel15/jbmath/jbmath.c
Normal file
@@ -0,0 +1,10 @@
|
||||
float circumf(float diameter)
|
||||
{
|
||||
const float pi = 3.14159265;
|
||||
return (pi * diameter);
|
||||
}
|
||||
|
||||
float area(float length, float height)
|
||||
{
|
||||
return (length * height);
|
||||
}
|
3
kapitel15/jbmath/jbmath.h
Normal file
3
kapitel15/jbmath/jbmath.h
Normal file
@@ -0,0 +1,3 @@
|
||||
float circumf(float diameter);
|
||||
float area(float length, float height);
|
||||
long jbpow(int x, int n);
|
10
kapitel15/jbmath/jbpow.c
Normal file
10
kapitel15/jbmath/jbpow.c
Normal file
@@ -0,0 +1,10 @@
|
||||
long jbpow(int x, int n)
|
||||
{
|
||||
long num = 1;
|
||||
int i;
|
||||
for(i = 0; i<n; i++)
|
||||
{
|
||||
num = num * x;
|
||||
}
|
||||
return num;
|
||||
}
|
12
kapitel15/jbmath/usemath-dyn.c
Normal file
12
kapitel15/jbmath/usemath-dyn.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <jbmath.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("En cirkel med diametern 5.5 har omkretsen %.3f\n",
|
||||
circumf(5.5));
|
||||
printf("En rektangel med sidorna 3 och 8.5 har arean %.3f\n",
|
||||
area(3, 8.5));
|
||||
printf("5 upphöjt till 6 är %ld\n", jbpow(5, 6));
|
||||
return 0;
|
||||
}
|
12
kapitel15/jbmath/usemath.c
Normal file
12
kapitel15/jbmath/usemath.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include "jbmath.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("En cirkel med diametern 5.5 har omkretsen %.3f\n",
|
||||
circumf(5.5));
|
||||
printf("En rektangel med sidorna 3 och 8.5 har arean %.3f\n",
|
||||
area(3, 8.5));
|
||||
printf("5 upphöjt till 6 är %ld\n", jbpow(5, 6));
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user