Answer to Question #336476 in C++ for krt

Question #336476

2 dimentional arrays that determines the odd number among 12 inputs



1
Expert's answer
2022-05-02T18:04:59-0400
#include <iostream>
using namespace std;
int main() {
    const int line = 3;
    const int col = 4;
    int array[line][col] = {};
    int i,j;
    cout << "Enter twelve numbers:\n";

        
    for( i=0; i<line; ++i)   {
        for( j=0; j<col; ++j)  {
            cin >> array[i][j];
            if(!cin)   {
                cout << "Bad input\n";
                return 1;
            }
        }
    }
    cout<<"Odd: ";
    for( i=0; i<line; ++i)   {
        for( j=0; j<col; ++j)  {
            if(array[i][j]%2==1)
                cout<<array[i][j]<<' ';
                 }
    }
    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
APPROVED BY CLIENTS