Program to illustrate Student Info

#include<iostream.h>
#include<string.h>
#include<conio.h>
struct student
        {
            char name[20],DOB[8];
            int RollNumber,m;
        }s[5];
void     main()
    {
        int i,j,temp;
        char temp1[20];
        for(i=0;i<5;i++)
        {
        cout<<"\n Enter the name of student : "<<i;
        cin>>s[i].name;

        cout<<"\n Enter the marks of student : "<<i;
        cin>>s[i].m;
        cout<<"\n Enter the DOB of  student : "<<i;
        cin>>s[i].DOB;
        cout<<"\n Enter the RollNumber of  student : "<<i;
        cin>>s[i].RollNumber;
    }
        for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
    {
        if(s[i].m>s[j].m)
    {
        temp=s[j].m;
        s[j].m=s[i].m;
        s[i].m=temp;
        temp=s[j].RollNumber;
        s[j]. RollNumber =s[i]. RollNumber;
        s[i]. RollNumber =temp;
        strcpy(temp1,s[j].DOB);
        strcpy(s[j].DOB,s[i].DOB);
        strcpy(s[i].DOB,temp1);
        strcpy(temp1,s[j].name);
        strcpy(s[j].name,s[i].name);
        strcpy(s[i].name,temp1);
    }
    }
        for(i=0;i<5;i++)
    {
        cout<<"\n Name : "<<s[i].name<<" \t Marks :  "<<s[i].m<<"\tDOB : "<<s[i].RollNumber;
    }
        getch();
        return(0);
}}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|