Making a benchmark, i have tested and figured out interesting results.
//gcc -o code_in_c.exe code_in_c.c #include <stdio.h> int main() { int a, b, c, d, r; while (scanf("%d %d %d %d", &a, &b, &c, &d) != -1){ r = a + b * c + d; printf("%d\n", r); } return 0; } and second file for cpp
//g++ -o code_in_cpp.exe code_in_cpp.cpp #include <cstdio> int main(){ int a, b, c, d, r; while (scanf("%d %d %d %d", &a, &b, &c, &d) != -1){ r = a + b * c + d; printf("%d\n", r); } return 0; } it's the same code, except for first two lines. the program need to read 4 integers from every line perform arithmetic operations (multiply two integers from middle) and add from margins
1 2 3 4 -> 1 + (2 * 3) + 4 -> 1 + 6 + 4 -> 11 so, testing this with random numbers on a 150 000 lines give me results for cpp
Running "code_in_cpp.exe", press ESC to terminate... Program successfully terminated exit code: 0 time consumed: 2.37 sec time passed: 4.34 sec peak memory: 2162688 bytes and for c.
Running "code_in_c.exe", press ESC to terminate... Program successfully terminated exit code: 0 time consumed: 2.87 sec time passed: 4.57 sec peak memory: 2162688 bytes So my question is what depends on running time?
(both was running on same machine)
stdio.handcstdioheader files (and functions implemented therein).-O3) to get meaningful results.