Tuesday, October 5, 2010

DISPLAYING OF STUDENT DETAILS USING STATIC FUNCTION

Ex N0.:1c              DISPLAYING OF STUDENT DETAILS USING STATIC FUNCTIONS
4-8-10
AIM:
To display a no.of student details using static functions.
ALGORTHIM:
Step 1: Start the program.
Step 2: Get the no. of students from the user.
Step 3: Get the name and roll no.
Step 4: Enter the no. of subjects required.
Step 5: Get the marks.
Step 6: The total and average are displayed
Step 7: The step 3 to step 6 is repeated for the given no. of students.
Step 8: End the program.
PROGRAM:
#include<iostream.h>
#include<conio.h>
class stud
{
int i,n,roll no.;
char a[20];
int marks[50],total;
float avg;
public:
int k;
int j;
static int count;
void getdetails()
{
cout<<”\nEnter the name and roll no,”;
cin>>a;
cin>>roll no.;
cout<<”\n Enter the number of subjects”;
cin>>n;
total=0;
for(i=0;i<n;i++)
{
cin>>marks[i];
cout<<endl;
total+=marks[i];
}
avg=(total n);
}
void display()
{
cout<<”STUDENT”<<cout<<endl;
cout<<”NAME”<<a<<endl<<”ROLL NO.”<<roll no<<endl<<endl;
for(i=0;i<n;i++)
{
cout<<”MARK”<<i+1<<”:”<<marks[i]<<endl;
}
cout<<”TOTAL”<<total;
cout<<”AVERAGE”<<avg;
}
static void showcount(void)
{
count++;
cout<<endl<<”      STUDENT     “<<count<<end;
}
};
int student::count;
void main()
{
clrscr();
student 5;
cout<<”\nEnter the number of students”;
cin>>s.j;
for(s.k=0;s.k<s.j;s.k++)
{
student::showcount();
s.getdetails();
s.display();
}
getch();
}

RESULT:
Thus a no. of student details are obtained using static members and the output is verified successfully.