Answers for "pointer"

C++
3

pointer

Variable is used to store value
Pointer is used to store addresss of value
Posted by: Guest on May-27-2021
1

pointer

/*
**use of pointers is that here even if we change the value of c since the adderss is
* of c is assigned to pc it *pc will also get modified*/
int* pc, c;
c = 5;
pc = &c;
*pc = 1;
printf("%d", *pc);  // Ouptut: 1
printf("%d", c);    // Output: 1
Posted by: Guest on May-27-2021
0

pointer

As discussed earlier, 'p' is a pointer to 'a'. Since 'a' has a value of 10, so '*p' is 10. 'p' stores the address of a. So the output p = 0xffff377c implies that 0xffff377c is the address of 'a'. '&p' represents the address of 'p' which is 0xffff3778. Now, '*&p' is the value of '&p' and the value of '&p' is the address of 'a'. So, it is 0xffff377c.
Posted by: Guest on June-20-2021
0

pointer

#include <iostream>

float average(float a[])
{
    int i;
    float avg, sum=0;
    for(i=0;i<8;++i)
    {
        sum+= a[i];
    }
    avg = sum/8;
    return avg;
}

int main(){
	float b, n[ ] = { 20.6, 30.8, 5.1, 67.2, 23, 2.9, 4, 8 };
	b = average(n);
  	std:: cout << "Average of numbers = " << b << std::endl;
	return 0;
}
Posted by: Guest on June-20-2021
0

pointer

#include <iostream>
// by using increment sign we know whole array
int main()
{
	using namespace std;
	int ar[] = { 1,2,3,4,5,6,7,8,9,10 };
	for (int m : ar)
	{
		cout << m << endl;
	}
	return 0;
}
Posted by: Guest on June-20-2021
0

pointer

p = 0xffff377c
*p = 10
&p = 0xffff3778
*&p = 0xffff377c
Posted by: Guest on June-20-2021
0

pointer

Size of arr[] 24
Size of ptr 4
Posted by: Guest on July-18-2021

Browse Popular Code Answers by Language