/*write a c program to create student structure having the field
roll_no,name,class,pass the entire structure to function and display
structure elements */
#include<stdio.h>
#include<conio.h>
struct stud
{
int roll_no;
char stud_name[20];
char clas[20];
};
struct stud s[4];
void main()
{
int i;
void pass_struct(struct stud);
clrscr();
for(i=0;i<4;i++)
{
printf("\nenter the roll no :");
scanf("%d",&s[i].roll_no);
printf("\nenter the student name :");
flushall();
scanf("%s",&s[i].stud_name);
flushall();
printf("\nenter the class :");
scanf("%s",&s[i].clas);
}
printf("\nroll no\tname\ttclass");
for(i=0;i<4;i++)
{
pass_struct(s[i]);
}
getch();
}
void pass_struct(struct stud b)
{
printf("\n%d\t%s\t%s",b.roll_no,b.stud_name,b.clas);
}
/*
enter the roll no :1
enter the student name :santish
enter the class :ty
enter the roll no :2
enter the student name :mahi
enter the class :s
enter the roll no :3
enter the student name :peer
enter the class :fy
enter the roll no :4
enter the student name :ashok
enter the class :ty
roll no name tclass
1 santish ty
2 mahi s
3 peer fy
4 ashok ty
*/
No comments:
Post a Comment