All pastes #1387757 Raw Edit

record 4.

public text v1 · immutable
#1387757 ·published 2009-04-10 05:23 UTC
rendered paste body
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#define N 2

struct student {
    char name[25];
    int rollno;
    float marks[3];
    float total;
    float avg;
}stud[N];
void input() {
    for (int i=0;i<N;i++) {
        stud[i].total=0;
        cout<<"------------INPUT STUDENT DETAILS------------";
        cout<<"\n\nStudent "<<i+1<<": ";
        cout<<"\n\nEnter student name: ";
        gets(stud[i].name);
        cout<<"Enter roll no: ";
        cin>>stud[i].rollno;
        cout<<"Enter the marks :\n";
        for (int m=0;m<3;m++) {
            cin>>stud[i].marks[m];
            stud[i].total+=stud[i].marks[m];
            stud[i].avg=(stud[i].total/3);
        }
        clrscr();
    }
}
void display() {
    clrscr();
    cout<<"\n\n\n------------STUDENT DETAILS------------";
    for (int i=0;i<N;i++) {
        cout<<"\n\nStudent "<<i+1<<": ";
        cout<<"\n\nStudent name: ";
        puts(stud[i].name);
        cout<<"Roll no: "<<stud[i].rollno;
        cout<<"\nMarks:";
        for (int m=0;m<3;m++)
            cout<<"\n"<<stud[i].marks[m];
        cout<<"\nTotal: "<<stud[i].total;
        cout<<"\nAverage: "<<stud[i].avg;

        cout<<"\n\n------------------------";
    }
}
void main() {
    clrscr();
    input();
    display();
    getch();
}