Back to General discussions forum
Task 1 "Sum A B" have incorrect sample! I am amazed that no one noticed this error until now.
#include <stdio.h>
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
printf("%d\n", a + b);
return 0;
}
According to the standard of C language, type "int" is not obliged to hold numbers above 32767. You must use "long" here.
P.S. C is a language designed for pedants, nerds and perfectionists.
These days, I reckon you'll have trouble finding a C compiler that holds an int in less than 4 bytes. My compiler holds a short in 2 bytes, an int and a long in 4 bytes and a long long in 8 bytes.
Huh! Interesting point! Thank you :)
My opinion is exactly what Quandray says, truly C compilers with 16-bit
ints are used now in industry only for small MCU programming!
But I also do know that some students still use Borland C/C++ which I remember from the times I myself was learning C...
So I'll think a bit - what is better, change the sample to long
or perhaps to reduce the range
of the numbers generated for the first task (because it is probaby not very important).
I think it is better to reduce numbers to be able to solve this problem in Brainfuck too.
Yeah! That is also good point!
So I changed them to not exceed 16000
, hence the sum should be suitable for 16-bit signed int!
Thank you for the insight!