Exercise Complete this program by filling use only pointer v

Exercise Complete this program by filling use only pointer variables when instruct This program is to test your knowledge symbols. Exercise 2: Run the program with the follow here LAB 9.2 Dynamic Memory Retrieve program dyna from the La The code is as follows: This program demonstrates the use of dynamic variables PLACE YOUR NAME HERE finclude kiostream using namespace std; const int MAXNAME 10

Solution

#include <iostream>

using namespace std;

const int MAXNAME = 10;

int main()
{
int pos;
char *name;
int *one;
int *two;
int *three;
int result;

//FILL in Code to allocate the integer variable one here
one = new int;

//FILL in Code to allocate the integer variable two here
two= new int;

//FILL in Code to allocate the integer variable three here
three = new int;

//FILL in Code to allocate the character array pointed to the name
name= new char[MAXNAME];

cout<< \"Enter your Last name with exactly 10 character.\" <<endl;
cout<< \"if you name has < 10 character then repeat last letter.\"<<endl
<< \"Blank at the end do not count.\"<<endl;

for(pos=0;pos< MAXNAME; pos++)
{
/* read a character in to name array
without using bracket script */
cin>>*(name+pos);


}
cout<<\"Hi \";
for(pos=0;pos< MAXNAME; pos++)
{
/* print a character from name array
without using bracket script */
cout<<*(name+pos);


}
cout<<endl;
cout<<\"Enter Three Integer number separated by space \"<<endl;
//read three number
cin>> *one>> *two>> *three;

cout<<\"The Three Numbers are: \";
//print three number
cout<<\" \"<<*one <<\" \"<<*(two)<<\" \"<<*(three) <<endl;


//calculate sum of three number
result=*one+*two+*three;

//print sum of three number
cout<<\"The sum of three values is : \"<<result<<endl;

//deallocate one, two, three and name
delete one;
delete two;
delete three;
delete[] name;

return 0;
}// End of main

==========================================================

output sample 1:-

Enter your Last name with exactly 10 character.
if you name has < 10 character then repeat last letter.
Blank at the end do not count.
rajjajraaa
Hi rajjajraaa
Enter Three Integer number separated by space
5 6 9
The Three Numbers are: 5 6 9
The sum of three values is : 20

---------------------------------------------------

output sample 2:-

Enter your Last name with exactly 10 character.
if you name has < 10 character then repeat last letter.
Blank at the end do not count.
jajrararaa
Hi jajrararaa
Enter Three Integer number separated by space
2 6 8
The Three Numbers are: 2 6 8
The sum of three values is : 16

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask

Thanks a lot

 Exercise Complete this program by filling use only pointer variables when instruct This program is to test your knowledge symbols. Exercise 2: Run the program
 Exercise Complete this program by filling use only pointer variables when instruct This program is to test your knowledge symbols. Exercise 2: Run the program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site