Code Competitions

Coding competition

Wednesday, 12 June 2013

program to display student record using pointer type objects

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class student
{
    public:
    int rn,n;
    int dd,mm,yy;
    char *name;
    public:
    void display()
    {
        cout<<"\nthe roll number "<<rn;
        cout<<"\nthe name of student "<<name;
        cout<<"\nthe date of birth "<<dd<<" "<<mm<<" "<<yy;
    }
};
void main()
{
    class student *s,*p;
    s=p;
    clrscr();
    int n;
    cout<<"enter the number of students ";
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cout<<"enter the record of "<<i+1<<" student ";
        cout<<"\nenter the roll number ";
        cin>>s[i].rn;
        cout<<"enter the name of student ";
        gets((s+i)->name);
        cout<<"enter the date of birth ";
        cin>>s[i].dd>>s[i].mm>>s[i].yy;
    }

    for(i=0;i<n;i++)
    {
        cout<<"\nthe record of student "<<i+1<<"\n";
        (s+i)->display();
    }
    getch();
}

2 comments:

  1. how to sort alphabetically dynamically declared array of studentds using structures?

    ReplyDelete
    Replies
    1. is program me student name nahi aa raha hai

      Delete