Professional Documents
Culture Documents
Rahmacplab 12
Rahmacplab 12
Task 02
#include<iostream>
#include<string>
using namespace std;
void main()
{
string blue;
string* ptr = &blue;
cout << " Enter your string: ";
cin >> blue;
int len = blue.length();
cout <<" Length of string : "<< len <<endl<< endl;
system("pause");
}
RAHMA ZAMIR BSCS 1-A 02-134222-096
Task 03
#include<iostream>
using namespace std;
int main()
{
int arr[5];
int* ptr = arr;
int temp;
for (int x = 0; x < 5; x++)
{
cout << " Enter element " << x + 1 << " of the array: ";
cin >> ptr[x];
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if (arr[i] > arr[j])
{
temp = ptr[i];
ptr[i] = ptr[j];
ptr[j] = temp;
}
}
}
for (int k = 0; k < 5; k++)
{
cout << ptr[k];
}
}