r/codereview • • Nov 03 '26

C/C++ [C] Bro what is this code 💀🥀

Somone don't know about C's global variables

(Sorry for bad formatted code)

#include <stdio.h>

int x = 0;

void add()

{

x = x + 1;

}

void subtract()

{

x = x - 1;

}

void multiply()

{

x = x * 2;

}

int main()

{

add();

add();

multiply();

subtract();

printf("%d\n", x);

return 0;

}

0 Upvotes

2 comments sorted by

1

u/Boarlock98 17d ago

Does C/C++ have var++ and var-- like CSharp? Also what are global vars, like fields?