Well only one more week left so don't have to worry about it after then
heres what I got:
I'm getting an error towards the end of the program saying I have too many identifiers and MAX is an undeclared identifier..can anyone help me out with this?
Also Can someone point me in the right direction to solving these?
Implements an array of ints using pointer notation and displays array elements by incrementing a pointer
Creates a dynamic array, assigns it values and displays its content,Using only pointer notation
Implements a function that is passed a pointer as an argument (use function prototype). Function definition displays string content using only pointers
Thanks!
heres what I got:
Code:
//• Declares, initializes, displays the contents of pointers to an int.* //• Assigns one pointer to another pointer.* //• Compares pointers for equality.* //• Implements an array of ints using pointer notation and displays array elements by incrementing a pointer. //• Implements a C-string using pointer notation and displays result of incrementing its pointer.* //• Implements a function that is passed a pointer as an argument (use function prototype). Function definition displays string content using only pointers. //• Creates a dynamic array, assigns it values and displays its content,Using only pointer notation. //MS Visual Studio Academic Edition #include <iostream> #include <stdlib.h> #include <fstream> using namespace std; int main() { int i=10; int *j; j=&i; cout<<"\n ---------- Addresses of Variables --------- \n"<<endl; cout<<"Address of i = "<<&i<<endl; cout<<"Address of j = "<<&j<<endl; cout<<"\n ---------- Values of Variables -------- \n"<<endl; cout<<"value of i = "<<i<<endl; cout<<"value of j = "<<j<<endl; cout<<"value of *&i = "<<*&i<<endl; cout<<"value of *j = "<<*j<<endl; cout<<"\n *j = 5 \n"<<endl; *j=5; cout<<"value of *j after modification = "<<*j<<endl; cout << boolalpha //compares pointers for equality << "The true expression 5 != 2 yields: " << (5 != 2) << endl << "The false expression 40 == 10 yields: " << (40 == 10) << endl; int *onePtr, *twoPtr, a = 10; //Assigning a pointer to another pointer onePtr = &a; *onePtr = 40; cout << a << endl; // outputs 40 cout << *onePtr << endl; // outputs 40 twoPtr = onePtr; // same as twoPtr = &a; cout << *twoPtr << endl; // outputs 40 int i_array[MAX] = { 0,1,2,3,4,5,6,7,8,9 }; int *i_ptr, count; float f_array[MAX] = { .0, .1, .2, .3, .4, .5, .6, .7, .8, .9 }; float *f_ptr; i_ptr = i_array; f_ptr = f_array; for (count = 0; count < MAX; count++) printf("%d\t%f\n", *i_ptr++, *f_ptr++); return 0; }
Also Can someone point me in the right direction to solving these?
Implements an array of ints using pointer notation and displays array elements by incrementing a pointer
Creates a dynamic array, assigns it values and displays its content,Using only pointer notation
Implements a function that is passed a pointer as an argument (use function prototype). Function definition displays string content using only pointers
Thanks!
Comment