You are on page 1of 2

Task no 1:

#include<iostream>
using namespace std;
int cube(int b);
int main()
{
int a;
int *b;
cout << "enter a= ";
cin >> a;
b = &a;
cout << "The orignal number is " << a << endl;
cout << "cube of the number is " << cube(*b) << endl;

system("pause");
return 0;
}
int cube(int b)
{
int c;
c = (b*b*b);
return c;
}

Task no 2:

#include<iostream>
using namespace std;
void odd(int arr[]);
int main()
{
int arr[10] = { 2,13,45,7,9,8,34,12,23,10 };
for (int i = 0;i < 10;i++)
{
if (i % 2 == 0)
{
arr[i] = arr[i] + 1;
cout << "Add 1 in even index[" << i << "]" << "= " << arr[i] <<
endl;
}
}
cout << "\nBefore odd function calling Array\n";
for (int i = 0;i < 10;i++)
{
if (i % 2 != 0)
{
cout << "Array odd index[" << i << "]" << "= " << arr[i] << endl;
}
}

cout << "\nAfter odd function calling Array\n";

odd(arr);

system("pause");
return 0;
}
void odd(int arr[])
{

int *pr;
pr = arr;
for (int i = 0;i < 10;i++)
{
if (i % 2 != 0)
{
*(pr + i) = *(pr + i) + 2;
cout << "Add 2 in odd index[" << i << "]" << "= " << *(pr + i) <<
endl;
}
}

Task no 3:

You might also like