Language C include int main return 0 Solutioninclude using
Language C++
#include <iostream>
int main() {
return 0; }
Solution
#include <iostream>
using namespace std;
/*
*(p+i) will print the array p sequentially for every index in array p
while *p+i will print the value of array p[0] and add i to it since *p points to p[0] by default and i is added to it at every step.
*/
int main()
{
int i = 5, j=51, k=62;
int data[5] = {10, 20, 30, 40, 50};
char my_cstring[8] = \"the fox\";
int *p = NULL;
char *pc = NULL;
p = data;
pc = my_cstring;
cout << \"\ Part c\ \";
cout << \"Using indexing, Integer Array: \";
for (int i = 0; i < 5; ++i)
{
cout << data[i] << \" \";
}
cout << endl;
cout << \"Using indexing, Character Array: \";
for (int i = 0; i < 8; ++i)
{
cout << my_cstring[i] << \" \";
}
cout << endl;
cout << \"\ Part d\ \";
// part d
for (int i = 0; i < 5; ++i)
{
cout << *p++ << \" \";
}
cout << endl;
p = data;
cout << \"\ Part e\ \";
j = 0;
cout << \"Using Pointer, Integer Array: \";
while(j < 5)
{
cout << *(p+j) << \" \";
j++;
}
cout << endl;
i = 0;
cout << \"Using Pointer, Character Array: \";
while(i < 8)
{
cout << *(pc+i) << \" \";
i++;
}
cout << endl;
cout << \"done\"<<endl;
return 0;
}
/*
output:
Part c
Using indexing, Integer Array: 10 20 30 40 50
Using indexing, Character Array: t h e f o x
Part d
10 20 30 40 50
Part e
Using Pointer, Integer Array: 10 20 30 40 50
Using Pointer, Character Array: t h e f o x
done
*/

