-1

Why the value of C is not changing when i use c=c++; instruction.

Code

#include <stdio.h>
int main()
{
int t, c=0,d;
scanf("%d",&t);
while(t--)
{
    int n;
    scanf("%d",&n);
    if(n>=50)
    {
        c=c++;
        printf("%d\n",c);
    }
}

    return 0;
}
EsmaeelE
  • 2,331
  • 6
  • 22
  • 31

1 Answers1

5
c=c++;

This keeps on resetting the value of c.

Either do:

c++;

or:

c+= 1;

Dont do both increment and assignment.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122