Saturday, 18 February 2017

C++ program , entering and showing student record through structure and function

In this program we will learn how to enter and show record of student through functions and structure.
The code is given below.


//CodeStarts

#include<iostream>
#include<conio.h>

using namespace std;

struct stu{
          char rol[15],dep[20],sub[30],inc[50];
};
void show(stu &s1);
void input(stu &s1);

int main()
{
          stu s1;
         
           input( s1);
          show (s1);
         
          getch();
         
}

void input(stu &s1)
{
          cout<<"Enter roll#"<<endl;
          cin>>s1.rol;
         
          cout<<"Enter department"<<endl;
          cin>>s1.dep;
         
          cout<<"Enter main subject"<<endl;
          cin>>s1.sub;
         
          cout<<"Enter class incharge"<<endl;
          cin>>s1.inc;
}

void show(stu &s1)
{
cout<<"=============OUTPUT========================"<<endl;

 cout<<s1.rol<<" has depatment "<<s1.dep<<" and studying "<<s1.sub<<" with Incharge "<<s1.inc;

}

//Code ends


Share:

0 comments:

Post a Comment