mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-05-13 00:43:43 +05:30
39 lines
856 B
C
39 lines
856 B
C
/*
|
|
* static-vs-const-variable.c
|
|
*
|
|
* Author: Intel A80486DX2-66
|
|
* License: Creative Commons Zero 1.0 Universal or Unlicense
|
|
* SPDX-License-Identifier: CC0-1.0 OR Unlicense
|
|
*/
|
|
|
|
#include <inttypes.h>
|
|
#include <math.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#ifndef M_PI
|
|
# define M_PI 3.1415926535897932384626433832795028841971693993751058209749445922
|
|
#endif
|
|
|
|
uint16_t frequently_called(uint8_t i);
|
|
|
|
uint16_t frequently_called(uint8_t i) {
|
|
static uint16_t variable_1 = 2;
|
|
const uint16_t variable_2 =
|
|
(uint16_t) (
|
|
(pow(10, floor(log10(M_PI))) + pow(10, ceil(log10(M_PI)))) / 2
|
|
);
|
|
static const uint16_t variable_3 = 3;
|
|
|
|
return variable_1 * variable_2 * variable_3 * i;
|
|
}
|
|
|
|
int main(void) {
|
|
for (uint8_t i = 1; i <= 16; i++) {
|
|
printf("f(%02" PRIu8 ") = %" PRIu16 "\n", i, frequently_called(i));
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|