c - What is wrong with this scanf usage? -


here 5 digit number input. want program calculate sum of digits , when run program in dev compiler stops responding , give 255 output every 5 digit number.

#include<stdio.h>  void main() {     int n, a, b, c, d, e, f;     printf("entre no ");     scanf("%d",n);      = n % 10;     n = n / 10;     b = n % 10;     n = n / 10;     c = n % 10;     n = n / 10;     d = n % 10;     n = n / 10;     e = n;     f = (a + b + c + d + e);     printf("sum of 5 digit=%d",f); } 

the expected output sum of 5 digits.

but stops responding , shows dialog box asking me close program. after closing program gives output of 255, whatever input number is.

change statement

scanf("%d",n);            ^^ 

to

scanf("%d", &n);            ^^^^ 

take account according c standard function main without parameters shall declared like

int main( void ) 

Comments