Code # 01
Code # 01
Code # 01
#include <iostream>
int main() {
int n;
cin >> n;
if (n <= 0) {
return 1;
int arr[n];
cout << "Enter " << n << " integers, separated by spaces:" << endl;
int sum = 0;
sum += arr[i];
}
OutPut:
Code # 02:
#include <iostream>
int main() {
int n;
cin >> n;
if (n <= 0) {
return 1;
int arr[n];
cout << "Enter " << n << " integers, separated by spaces:" << endl;
int max_position = 0;
int min_position = 0;
max_value = arr[i];
max_position = i;
min_value = arr[i];
min_position = i;
cout << "Maximum value: " << max_value << " at position " << max_position + 1 << endl;
cout << "Minimum value: " << min_value << " at position " << min_position + 1 << endl;
return 0;
OutPut:
Code # 03:
#include <iostream>
int main() {
int n;
cin >> n;
if (n <= 0) {
return 1;
}
int arr[n];
cout << "Enter " << n << " integers, separated by spaces:" << endl;
arr[n - i - 1] = temp;
return 0;
OutPut:
Code # 04:
#include <iostream>
int main() {
int n;
cin >> n;
if (n <= 0) {
return 1;
int arr[n];
cout << "Enter " << n << " integers, separated by spaces:" << endl;
if (arr[i] == searchValue) {
arr[i] = replaceValue;
found = true;
if (found) {
} else {
cout << "Value not found in the array. No replacement performed." << endl;
return 0;
OutPut:
Code # 05:
#include <iostream>
#include <vector>
int main() {
int n;
cin >> n;
if (n <= 0) {
vector<int> arr(n);
cout << "Enter " << n << " integers, separated by spaces:" << endl;
int evenCount = 0;
int oddCount = 0;
vector<int> evenNumbers;
vector<int> oddNumbers;
if (arr[i] % 2 == 0) {
// Even number
evenCount++;
evenNumbers.push_back(arr[i]);
} else {
// Odd number
oddCount++;
oddNumbers.push_back(arr[i]);
cout << "Count of even numbers: " << evenCount << endl;
cout << "Count of odd numbers: " << oddCount << endl;
return 0;
OutPut: