0
This program stores 5 numbers in array and then displays them, but imagining that I want to save large numbers as:
8.12415367228151 / 119.038571952966 / 169.873349402464 / 324.997128488111 / -283.262126034417
What modification can I make for the program to store numbers of this size but also to store smaller numbers like: 20/30/40/-50/-60
I’ve tried to change the int values[5]
for long int value [5]
and for other types of data types but I get nowhere.
#include <stdio.h>
#include <stdlib.h>
int main() {
int values[5];
printf("Enter 5 integers: ");
for (int i = 0; i < 5; ++i) {
scanf_s(" %d", &values[i]);
}
printf("Displaying integers: ");
for (int i = 0; i < 5; ++i) {
printf("%d\n", values[i]);
}
system("pause");
return 0;
}
See <Limits> for the minimum and maximum limits of the values that can be stored in the various types of data.
– anonimo
If you want to work with arbitrary precision numbers use a specific library, such as GMP - The GNU Multiple Precision Arithmetic Library [https://gmplib.org/].
– anonimo