Define a structure of student class, C/C++ Programming

Define a structure of student class: 

Write a program to define a structure of student record in C.

class student

{

char name[20];

int roll_no;

int marks[2];

float average;

 

public:

 void input();

 void output();

 float calci();

 friend  void rank(student ,student );

 };

 

 void student:: input()

 {

 cout << "enter the name ,rollno,marks of 2 subjects\n";

 cin>> name >> roll_no >>marks[0]>>marks[1];

 }

 

 void student :: output()

 {

 cout<

 }

 

 float  student :: calci()

 {

return average= float(marks[0]+ marks[1]) / 2;

 }

 

 void rank(student a, student b)

     {

                if ( a.calci() > b.calci() )

 

                 cout << "the student e1 is best\n";

 

                 else

 

                 cout <<"the studentr e2 is best\n";

 

     }

 

 void main()

 {

 

 clrscr();

 student t[2];

 t[0].input();

// t[0].calci();

// t[0].output();

 

 

 t[1].input();

// t[0].calci();

 //t[1].output();

 

 rank(t[0],t[1]);

 getch();

 

 }

Posted Date: 10/19/2012 3:08:46 AM | Location : United States







Related Discussions:- Define a structure of student class, Assignment Help, Ask Question on Define a structure of student class, Get Answer, Expert's Help, Define a structure of student class Discussions

Write discussion on Define a structure of student class
Your posts are moderated
Related Questions
Introduction:  This assignment requires a knowledge of variables (integers, char types), loops, conditionals, switch, functions, char arrays, string arrays, number arrays, struc

to count number of occurances

Explain string constants in c language - Escape Sequences? Illustrations are "945", "hello", "well done", "5+3". The character constant (example 'x') isn't equivalent to the st

Call by reference: Arguments to a function can be passed in two way; one by call by value and other by call by reference.  Call by value is passed either through a constant

Private derivation If no specific derivation is listed, then a private derivation is supposed. If a new class is derived privately from its parent class, then: The priva

Stage One Define the specification of the program            Add two nxm size matrices   Stage Two Divide the program up into separate modules           Input Matrix         Ad


Scope Rules and Storage Classes The storage class verifies the life of a variable in terms of its duration or its scope. There are four storage classes : automatic static

Problem: (a) (i) What is a structure? (ii) How does a structure differ from an array? (b) Declare a structure, called account, that will contain the following data me

write a program to calculate gross salary and net salary using hra da pf in c++