10. Write cout statement to display 25 using pointer variable, not data variable
ID: 3585583 • Letter: 1
Question
10. Write cout statement to display 25 using pointer variable, not data variable. vold *Pointer int Data = 25; Pointer& Data 11. Write cout statement to display 67.89 using pointer variable, not data variable. void *Pointer, double Data = 67.89; Pointer & Data; 12. Write cout statement to display character 'A' using pointer variable, not data variable. void *Pointer; char Data = 'A'; Pointer = & Data; 13. Write cout statement to display string "Farzeen" using pointer variable, not data variable void Pointer; string Data "Parzeen", Pointer = & Data; 14. Suppose the address of memory location addressed by X is 002F0OFC What is the result of the output cout for the following statements? int X; int "XPtr XPtr++ CoutExplanation / Answer
(10) int main() {
void *Pointer;
int Data = 25;
Pointer = &Data;
int *intPtr = static_cast<int*>(Pointer);
cout<<*intPtr;
}
(11) int main() {
void *Pointer;
double Data = 67.89;
Pointer = &Data;
double *doublePtr = static_cast<double*>(Pointer);
cout<<*doublePtr;
}
(12) int main() {
void *Pointer;
char Data = 'A';
Pointer = &Data;
char *charPtr = static_cast<char*>(Pointer);
cout<<*charPtr;
}
(13) int main() {
void *Pointer;
string Data = "Farzeen";
Pointer = &Data;
string *stringPtr = static_cast<string*>(Pointer);
cout<<*stringPtr;
}
As can be seen from the code we need to cast the void pointer into the respective counter.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.