EX - 6
EX - 6
int main()
int n;
cin>>n;
int x[10]={1,2,3,4,5,6,7,8,9,10};
for(int i=0;i<10;i++)
cout<<" "<<x[i]*n<<endl;
return 0;
10
15
20
25
30
35
40
45
50
#include<iostream>
int main() {
int n;
cin >> n;
int arr[n];
if(arr[i] % 2 == 0) {
evenCount++;
} else {
oddCount++;
}
cout << "Number of even elements: " << evenCount << endl;
cout << "Number of odd elements: " << oddCount << endl;
return 0;
Enter 2 elements: 2
int main()
int i,j,n,m;
cout<<"enter n :";
cin>>n;
cout<<"enter m :";
cin>>m;
int x[n];
cin>>x[i];
int y[n];
cin>>y[j];
{
if (x[i]==y[j])
cout<<" "<<x[i];
return 0;
enter n :2
enter m :3
4
#include<iostream>
int main() {
int i,j,n;
cin>>n;
int x[n];
int y[n];
cin>>x[i];
cout<<x[i]<<" ";
cout<<endl;
for(i=0,j=(n-1);i<n;i++,j--)
y[j]=x[i];
cout<<y[i]<<" ";
cout<<endl;
return 0;
int main() {
int N;
cin >> N;
int arr[N];
cout << "Enter the elements of the array: " << endl;
if(N > 1) {
arr[N - 1] = temp;
}
cout << "Array after swapping first and last elements: " << endl;
return 0;
623451
#include <iostream>
int main() {
int M, N;
cin >> M;
cin >> N;
int matrix[M][N];
}
int sum = 0;
sum += matrix[i][j];
cout << "The sum of the elements of the matrix is: " << sum << endl;
return 0;
int main()
int r,c;
cin>>r;
cin>>c;
int x[r][c];
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
cin>>x[i][j];
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
cout<<x[i][j]<<" "; }
cout<<endl;
} int sum=0;
for(int i=0;i<r;i++)
for(int j=0;j<=i;j++)
sum=sum+x[i][j];
return 0;
123
456
789
int main() {
const int M = 3, N = 3;
int matrix[M][N];
cout << "Enter elements of the 3x3 matrix: " << endl;
maxElement = matrix[i][j];
}
cout << "The largest element in the matrix is: " << maxElement << endl;
return 0;
cout << "Enter the number of rows and columns of the first matrix (MxN): ";
cout << "Enter the number of rows and columns of the second matrix (PxQ): ";
if (N != P) { cout << "Matrix multiplication not possible. Number of columns of the first matrix must
equal the number of rows of the second matrix." << endl;
return 0;
cout << "Enter elements of the first matrix: " << endl;
} cout << "Enter elements of the second matrix: " << endl;
result[i][j] = 0; }
} cout << "The resultant matrix after multiplication is: " << endl;
return 0;
Enter the number of rows and columns of the first matrix (MxN): 2
Enter the number of rows and columns of the second matrix (PxQ): 2
85
20 13