Posted by MindBreaker at 2:21 PM
Read our previous post
suppose
you are given addresses of two array element at random?write a
program which can find the number of element b\w them?
program which can find the number of element b\w them?
Source
code
#include <iostream>
using namespace std;
void
func(int a,int
b,int *pointer)
{
for(a;a<b;a++)
{
cout<<*(pointer+a)<<" , ";
}
};
void
main()
{
int a,b;
int
*pointer1,*pointer2,*pointer;
cout<<"Enter
number 1 - 5"<<endl;
cout<<"Enter
a 1st number"<<endl;
cin>>a;
cout<<"Enter
a 2nd number"<<endl;
cin>>b;
int
ary[5]={2,4,6,8,10};
pointer= ary;
pointer1 =&a;
pointer2 =&b;
cout<<"Address
of 1st element"<<pointer1<<endl;
cout<<"Address
of 2nd element"<<pointer2<<endl;
func(a,b,pointer);
}
Output
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.