EPFL
2024-10-09
Memory
Topping et al., doi:10.3389/frsc.2021.786563, 2021
Fourment et al., doi:10.1186/1471-2105-9-82, 2008
Sum of natural numbers up to 10
sum = 1 + 2 + 3 + ... + 10
C code
#include <stdio.h>
int main() {
int n, i, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
for (i = 1; i <= n; ++i) {
sum += i;
}
printf("Sum = %d", sum);
return 0;
}
Basic elements
#include statement to import librariesmain() function with return value of 0Differences from Python and MATLAB
C compiler
once program is compiled, can run on machine it was compiled for without user having to install C
Python interpreter
user needs to install Python to run Python scripts
Go to Command Palette and open Preferences: Open Users Settings (JSON).
Copy the relevant information below (not the text between /* */):
{
/*
Other stuff
*/
"terminal.integrated.profiles.windows": {
/*
"PowerShell", "Command Prompt" profiles
*/
"MSYS2_UCRT64": {
"path": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"--login",
"-i"
],
"env": {
"MSYSTEM": "UCRT64",
"CHERE_INVOKING": "1"
}
}
}
"terminal.integrated.defaultProfile.windows": "MSYS2_UCRT64",
/*
More stuff
*/
}
source: GitHub