-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-main.c
55 lines (49 loc) · 1.08 KB
/
2-main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include "function_pointers.h"
/**
* is_98 - check if a number is equal to 98
* @elem: the integer to check
*
* Return: 0 if false, something else otherwise.
*/
int is_98(int elem)
{
return (98 == elem);
}
/**
* is_strictly_positive - check if a number is greater than 0
* @elem: the integer to check
*
* Return: 0 if false, something else otherwise.
*/
int is_strictly_positive(int elem)
{
return (elem > 0);
}
/**
* abs_is_98 - check if the absolute value of a number is 98
* @elem: the integer to check
*
* Return: 0 if false, something else otherwise.
*/
int abs_is_98(int elem)
{
return (elem == 98 || -elem == 98);
}
/**
* main - check the code for Holberton School students.
*
* Return: Always 0.
*/
int main(void)
{
int array[20] = {0, -98, 98, 402, 1024, 4096, -1024, -98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 98};
int index;
index = int_index(array, 20, is_98);
printf("%d\n", index);
index = int_index(array, 20, abs_is_98);
printf("%d\n", index);
index = int_index(array, 20, is_strictly_positive);
printf("%d\n", index);
return (0);
}