What is wrong with my code? ( C programming)

I want to create an arithmetic mean program. For e.g. n=6, (1+2+3+6)/4=3. n is the number which is given by the user. b is calculating the numbers, if n%a=0 (in the example 1,2,3,6). d is calculating the numbers (in the example the 4). In the end x=b/d and we will have the answer. But when I enter the n in the scanf, the program crashes. What is the problem? Sorry for the bad english, if it is bad.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
int n,a,b=0,d=0,x;
scanf("%d", &n);




printf("%d", x);

2 answers Last reply
More about what wrong code programming
  1. Ask yourself what result would you expect from trying to evaluate the expression:

  2. Oh, I'm stupid! Thanks! It's working!:) I rewrote the a to 1.
Ask a new question

Read More

Programming Apps