What is the difference between while(n--)and while(n=n-1)? When I use while(n=n-1)in my code, I can enter less than 1 number.
Example: first input 3, than input 3 times by one number (but this does not happen in while(n=n-1)). But when I use while(n--), this is normal.
My code is:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
long long inum;
scanf("%d", &n);
while(n--)
{
scanf("%lld", &inum);
if(inum == 0 || inum % 2 == 0)
{
printf("even\n");
}
else
{
printf("odd\n");
}
}
return 0;
}
source
share