Function returning a Structure


    #include <iostream.h>
    #include <conio.h>
    struct student
    {
        int student_roll_no ;
        int marks_in_subject1 ;
        int marks_in_subject2 ;
    } ;
    void main ()
    {
        struct student function ()  ;
        struct student t ;
        float result ;
        clrscr () ;
        t = function () ;
    cout<<"Student Record : \n";
    cout<<"Roll Number    : "<<t.student_roll_no;
    cout<<"Subject 1 marks  : "<< t.marks_in_subject1 ;
    cout<<"Subject 2 marks : "<< t.marks_in_subject2 ;
    getch () ;
    }
    struct student function ( )
    {
        struct student s1 = { 3032, 89, 78 } ;
        return ( s1 ) ;
    }

0 comments:

Post a Comment

 
 
 
 


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