I am getting errors during the compilation of this C program and is related to the declaration of the function. What is the problem here? When I declare void display(student);
it shows a warning but if I change to void display(struct student st)
it shows some errors.
#include<stdio.h>
void display(student);
void read_student(student);
struct student{
int roll;
char name[20],depart[20],sex,result;
float percent,marks[5],total;
};
void main(){
int n;
printf("enter the no of data you want to enter ??");
scanf("%d",&n);
struct student s[n];
for(int i=0;i<n;i++)
read_student(&s[i]);
printf("\n---------------------------------------------------Result Sheet --------------------------------------------------------------------");
printf("\nRoll No.\tName\t\tSex\tDepartment\t\tMarks\t\t\t\tTotal\tPercentage\tResult ");
printf("\n----------------------------------------------------------------------------------------------------------------------------------------");
printf("\n \t\t\t\tA\tB\tC\tD\tE\n");
printf("----------------------------------------------------------------------------------------------------------------------------------------");
for(int i=0;i<n;i++)
display(s[i]);
}
void display(struct student st){
printf("\n%2d\t%10s\t\t%c\t%10s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%4.2f\t %2.2f\t\t%c\n",st.roll,st.name,st.sex,st.depart,st.marks[0],st.marks[1],st.marks[2],st.marks[3],st.marks[4],st.total,st.percent,st.result);
}
void read_student(struct student *std){
int c=0,i;
printf("Enter the roll no:");
scanf("%d",&std->roll);
printf("enter the name:\n");
scanf("%s",std->name);
printf("enter Sex:\n");
scanf(" %c",&std->sex);
printf("Enter the department:\n");
scanf("%s",std->depart);
printf("enter the marks in 5 subjects:\n");
for(i=0;i<5;i++){
scanf("%f",&std->marks[i]);
std->total=std->total+std->marks[i];
if(std->marks[i]>=40)
c++;
}
if(c==5)
std->result='p';
else
std->result='f';
std->percent=(std->total/500)*100;
}