198k views
1 vote
Write a function which the counts the number of odd numbers and even numbers currently in the stack and prints the results.

1 Answer

2 votes

Answer:

See the code below and the algorithm explanation on the figure.

Step-by-step explanation:

The explanation in order to get the answer is given on the figure below.

Solving this problem with C. The program is given below:

#include <stdio.h>

int main(void) {

int n, Even=0, Odd=0, Zeros=0;

for (;;) {

printf("\\Enter the value the value that you want to check(remember just integers): ");

//IF we input a non-numeric character the code end;

if (scanf("%d", &n) != 1) break;

if (n == 0) {

Zeros++;

}

else {

if (n % 2) {

Even++;

}

else {

Odd++;

}

}

}

printf("for this case we have %d even, %d odd, and %d zero values.", Even, Odd, Zeros);

return 0;

}

Write a function which the counts the number of odd numbers and even numbers currently-example-1
User Wynona
by
8.2k points

No related questions found