I have this code in C, and for some reason instead of properly working with numbers, it outputs zero all the time. Can someone explain me what is going on here? I know C#, but not C.
#include <stdio.h>
int main(void) {
// I want to express 1/6n*(n + 1)(2n + 1)
int n = 1;
while(n != 0){
scanf("%d", &n);
printf("%d", 1/6 * n * (n + 1) * (2 * n + 1));
}
return 0;
}
Thanks in advance!
I am using Code::Blocks + GCC compiler.