Answer to Question #334651 in C++ for ahsan

Question #334651

Suppose we have a pointer to float data type which contains the memory address

value 100.

If we add the integer value 3 to this pointer, what will be the value of the pointer if float data

types are 4 bytes in length?


1
Expert's answer
2022-04-28T13:22:06-0400
#include <iostream>


using namespace std;


int main()
{
	cout << "Size of float is " << sizeof(float);
	float a = 2;
	float *fp=&a;
	/*suppose, that address value is 100
	Value after adding 3 will be more on 3*sizeof(float),
	that is 3*4=12, and ewsukt is 112
	Make a real example*/
	cout << "\nReal address value is " << fp;
	//difference will be 12 bytes
	cout << "\nReal address value after adding 3 " << fp+3;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS