What is the code for "par = par + 1"?

Asked

Viewed 63 times

-2

#include<stdio.h>
#include<locale.h> 

int main(){ 

    int par=0, num, i; 
    setlocale(LC_ALL,"Portuguese");
 
    for (i=1; i<=10; i++){
        printf("Informe número: "); 
        scanf("%d", &num);
            
        if (num%2==0){ 
            par=par+1;
        }
    }

    printf("\nQuantidade de números Pares: %d\n", par); 
    printf("Quantidade de números Impares: %d\n", 10-par); 
    
    return 0;
}

1 answer

3

This pair serves as an even number counter. Each even number typed, adds +1 in the Even variable.

in that case, one may also:

par += 1;

or:

par++;
  • AAAAAA draw, thanks brother, nice.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.