Lab_Exercises_Cpp
Lab_Exercises_Cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
string str1, str2, combined;
cout << "Enter first string: ";
cin >> str1;
cout << "Enter second string: ";
cin >> str2;
combined = str1 + str2;
cout << "Combined String: " << combined << endl;
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int arr[100], n;
cout << "Enter number of elements: ";
cin >> n;
cout << "Enter elements: ";
for (int i = 0; i < n; i++)
cin >> arr[i];
return 0;
}
3. Transpose of Matrix
#include <iostream>
using namespace std;
int main() {
int mat[10][10], trans[10][10], row, col;
cout << "Enter rows and columns: ";
cin >> row >> col;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int mat[10][10], n, sum = 0;
cout << "Enter size of square matrix: ";
cin >> n;
cout << "Sum of diagonal elements: " << sum << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string number;
cout << "Enter a number: ";
cin >> number;