Friday, May 30, 2014

WRITE A FUNCTION TO READ THE DETAILS OF A STUDENT AND THEN DISPLAY DETAILS IN CALLING FUNCTION

#include<stdio.h>
#include<conio.h>
typedef struct student
{
char name[20];
int rollno;
int age;
int marks[4];
}stu;
stu fun1(stu);
void main()
{
stu s1,s2;
int i;
clrscr();
s2=fun1(s1);
printf("the details of student is:\n");
printf("name-%s\nrollno-%d\nage-%d",s2.name,s2.rollno,s2.age);
for(i=0;i<4;i++)
{
printf("\nmarks in %d subject is- %d",i+1,s2.marks[i]);
}
getch();
}

stu fun1(stu s1)
{
int i;
printf("enter the name, rollno and age of student\n");
scanf("%s%d%d",s1.name,&s1.rollno,&s1.age);
printf("enter the marks in 4 subjects\n");
for(i=0;i<4;i++)
{
scanf("%d",&s1.marks[i]);
}
return(s1);
}

No comments:

Post a Comment