closed new to programming, variable always gives 0 as a result

0 votes
asked Dec 29, 2018 by Vale (120 points)
closed Jan 2, 2019 by Vale

why "M" only gives 0 as a result?

#include <iostream>

using namespace std;

int

main ()

{

  int cont, A, cont1, M;

  cont = 0;

  cont1 = 0;

  cin >> A;

  while (A != -1)

    {

      if (A >= 0)

{

  cont = cont + A;

  cont1 = cont1 + 1;

  cin >> A;

}

    }

  M = A / cont1;

  cout << "Value of A" << cont << endl << "value of cont1" << cont1;

  cout << endl << "media" << M;

  return 0;

}

closed with the note: solved

1 Answer

0 votes
answered Jan 1, 2019 by Admin (4,340 points)
What input are you providing for A?
commented Jan 2, 2019 by Vale (120 points)
edited Jan 2, 2019 by Vale
i fucked up, instaead of using "cont" as a variable for the operation M=x/y i used "A".
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...