Write a 'C' program to create student structure having field roll_no, stud_name, class. Pass this entire structure to function and display the structure elements.


#include

struct student
{
    int  roll_no;
    char stud_name[80];
    char stud_class[80];
};
struct student s[100];

void display(struct student [],int);

void main()
{
    int    n,i;
    clrscr();
    printf("\nHOW MANY RECORDS U WANT ::>  ");
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++)
    {
        printf("\nENTER ROLL NO. NAME AND CLASS OF                                     STUDENT%d::>\n",i + 1);
                   scanf("%d%s%s",&s[i].roll_no,s[i].stud_name,
                      &s[i].stud_class);
    }
    display(s,n);
    getch();
}
void display(struct student s[], int n)
{
    int i;
    printf("RECORD OF STUDENTS ::>\n");
    for (i = 0 ; i < n ; i++)
    {
        printf("\n%d\t%s\t%s",s[i].roll_no,s[i].stud_name,
                                   s[i].stud_class);
    }
}
/*OUTPUT::

HOW MANY RECORDS U WANT ::>  6

ENTER ROLL NO. NAME AND CLASS OF STUDENT1::>
101 Sachin FYBCA

ENTER ROLL NO. NAME AND CLASS OF STUDENT2::>
111 Pawan SYBCA

ENTER ROLL NO. NAME AND CLASS OF STUDENT3::>
595 Amey TYBCA

ENTER ROLL NO. NAME AND CLASS OF STUDENT4::>
333 Dipesh FYBCS

ENTER ROLL NO. NAME AND CLASS OF STUDENT5::>
654 Anshul SYBCS

ENTER ROLL NO. NAME AND CLASS OF STUDENT6::>
781 Santosh TYBCS
RECORD OF STUDENTS ::>

101     Sachin  FYBCA
111     Pawan   SYBCA
595     Amey    TYBCA
333     Dipesh  FYBCS
654     Anshul  SYBCS
781     Santosh TYBCS
*/
Write a 'C' program to create student structure having field roll_no, stud_name, class. Pass this entire structure to function and display the structure elements. Write a 'C' program to create student structure having field  roll_no, stud_name, class. Pass this entire structure  to function and display the structure elements. Reviewed by on April 24, 2015 Rating: 5
Powered by Blogger.