Exercise Complete this program by filling use only pointer v
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

