Store Student Detail using Function in C++

Here we will Store Student Detail using Function in C++, Program will Sore Student detail like roll-number, age and name

We have used two user Defined Functions in the program.

In this, the function void get_data() will stores the details from the user while the void put_data() will print that detail.

In a way, we can say that the function void get_data() will act as input and function void put_data() will act as output.

Here is a Diagram,


Here is the program,

#include<stdio.h>// for gets() function

// data member declare in globally
 int roll,age;
 char name[10];

// function member declaration
 void get_data();
 void put_data();

 void main(void)

     getdata(); // for input
     putdata();  // for output


 void get_data()
     cout<<"\nEnter roll no: "; cin>>roll;
     cout<<"Enter age : "; cin>>age;
     cout<<"Enter Name : ";

 void put_data()
    cout<<"\nDisplay Record";
    cout<<"\nRoll no : "<<roll;
    cout<<"\nStu. age: "<<age;
    cout<<"\nStu.Name: "<<name;
Enter roll no: 101
Enter age : 25
Enter Name : Rohit sherma

Display Record
Roll no : 101
Stu. age: 25
Stu.Name: Rohit sherma


In the Program inside the main() function getdata() and putdata() are declared while their definition is outside the main()

getdata() function will take the record from the user and store them while putdata function will display them into monitor, you can see in the above diagram.

Read also:

store student detail using function with structure in C++