0% found this document useful (0 votes)
6 views

Computer Programming Solved C++

Uploaded by

musasal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Computer Programming Solved C++

Uploaded by

musasal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Programming

Lab Tasks # 011

Department of Computer Science - BUIC


Section: BS CS (1-B)
Date: 4th Dec 2023

Exercises/Lab Journal # 11

Task 1
Declare an array of 4 by 5 size of integers and get user input to fill the array values.
Then, find the minimum values in the arrays.
Code:
#include <iostream>
using namespace std;
int main()
{
int arr[4][5], min = INT_MAX;
for (int i = 0; i < 4; i++) //i<4 for number of rows
{
for (int j = 0; j < 5; j++) //j<5 for number of columns
{
cout << "enter the " << i + 1 << "x" << j + 1 << " element: ";
cin >> arr[i][j];
if (arr[i][j] < min) min = arr[i][j];
cout << endl;
}
}
cout << min << " is the smallest element in the given array";

return 0;
}

Output:

Task 2
Write a program to input value in an array of type integer and size 6 by 7. Find out
the total number of even and odd values entered in the array.
Code:
#include <iostream>
using namespace std;
int main()
{
int arr[6][7], even = 0, odd = 0;
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 7; j++)
{
cout << "enter the " << i + 1 << "x" << j + 1 << " element: ";
cin >> arr[i][j];
if (arr[i][j] % 2 == 0) even++;
else odd++;
cout << endl;
}
}
cout << "total even numbers are " << even << endl;
cout << "total odd numbers are " << odd;
return 0;
}

Output:

THE END

You might also like