C++ program of calling a structure in a function

In this program we will learn, how to call a structure inside a function and insert its values outside the main()..

The code is given below with screenshot.

//Code starts



using namespace std;

struct student{

int id;

char name[15];


void show (student s1);

int main()


student s1;

show (s1);



void show (student s1)


cout<<“Enter Student name”<<endl;


cout<<“Enter your Roll Number”<<endl;


cout<<“Name: “<

cout<<“ID: “<<s1.id;


//Code ends



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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s