Posted by: Sourav | February 15, 2013

Passing a structure as an argument in c++


#include<iostream>
using namespace std;

struct Distance
{
int feet;
float inches;
};

int showstruct(struct Distance dd);

int main ()
{
Distance d1,d2;
cout<<“Enter the feet”<<endl; cin>>d1.feet;
cout<<“Enter the inches”<<endl; cin>>d1.inches;
cout<<“Enter the feet”<<endl; cin>>d2.feet;
cout<<“Enter the inches”<<endl; cin>>d2.inches;
showstruct(d1);

return 0;
}

int showstruct(struct Distance dd)
{
cout<<dd.feet;
cout<<dd.inches;
cout<<endl;
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: