Build a program that performs the following operations Decla

Build a program that performs the following operations: Declares three pointer variables called I Ptr of type int, cPtr of type char, and f Float of type float Declares three new variables called I Number of int type, f Number of float type, and c Character of char type Assigns the address of each nonpointer variable to the matching pointer variable Prints the value of each nonpointer variable Prints the value of each pointer variable Prints the address of each nonpointer variable Prints the address of each pointer variable

Solution

#include <iostream>

using namespace std;

int main()
{
// Pointer declaration
int *iPtr;
float *fFloat;
char *cPtr;

//Variable Declaration
int iNumber;
float fNumber;
char cCharacter;

//Assigning Pointer to a variable
iPtr = &iNumber;
fFloat = &fNumber;
cPtr = &cCharacter;

cout << iNumber << \" \" << fNumber << \" \" << cCharacter << endl;
cout << iPtr << \" \" << fFloat << \" \" << cPtr << endl;
cout << &iNumber << \" \" << &fNumber << \" \" << &cCharacter << endl;
cout << &iPtr << \" \" << &fFloat << \" \" << &cPtr << endl;

return 0;
}

Output

0 0 0x7ffd19c46324 0x7ffd19c46320 0x7ffd19c46324 0x7ffd19c46320 0x7ffd19c46338 0x7ffd19c46330 0x7ffd19c46328

 Build a program that performs the following operations: Declares three pointer variables called I Ptr of type int, cPtr of type char, and f Float of type float

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site