Answer to Question #300273 in C++ for chuchay

Question #300273

Write a C program using two dimensional arrays that determine the even numbers among the twelve input values from the keyboard and prints the list of these even numbers

1
Expert's answer
2022-02-20T15:38:53-0500
#include <stdio.h>

const int n = 12;
int arr[n];

int main() {

  int tarr[n];
  for (int i = 0, j = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0) {
      tarr[j++] = arr[i];
    }
  }

  for (int i = 0; i < j; i++) {
    cout << tarr[i] << " ";
  }

  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog