Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <iostream>

using namespace std;


int input(int arr[3][2])
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
cin>>arr[i][j];

}
cout << "array output" << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
cout << arr[i][j];
cout << "\t";

}
cout << endl;
}
return 0;
}
void sumofodd(int arr[3][2])
{
int sum = 0;
cout << "odd output" << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
if (arr[i][j] % 2 != 0)
{
cout << arr[i][j];
cout << "\t";
sum = sum + arr[i][j];
}
}
cout << endl;
}
cout << "sum = " <<sum<< endl;

int main()
{
int b[3][2];
cout << "Enter value in 2d array " << endl;
input(b);
sumofodd(b);

system("puase");
return 0;
}

You might also like