Here's the code I wrote:
#include<stdio.h>
#include<conio.h>
#define STU 3
#define SUB 3
void main()
{
int k,i;
struct student
{
int rno;
char name[20];
int marks[2];
int total;
float avg;
}sk;
for(k=1;k<=STU;k++)
{
printf("Enter the roll no and name of the student %d:",k);
scanf("%d%s",&sk.rno,&sk.name);
printf("Enter the marks:");
for(i=0;i<SUB;i++)
{
scanf("%d",&sk.marks[i]);
sk.total=sk.total+sk.marks[i];
}
sk.avg=sk.total/SUB;
}
printf("\nRollno\tName\tMarks\tTotal\tAvg\n");
for(k=1;k<=STU;k++)
{
printf("%d\t%s\t",sk.rno,sk.name);
for(i=0;i<SUB;i++)
printf("%d ",sk.marks[i]);
printf("%d\t%.3f\n",sk.total,sk.avg);
}
getch();
}
The program seems to be encountering an error while printing the details.
Please help!
Suggestions for improvement of the code are welcome!

New Topic/Question
Reply




MultiQuote






|