help in making structer assignment

I'm preparing this assignment for college but encountered some problems and i'm confused that where did i do wrong in it. I've tried using functions and seems i'm failed. anyways here's my code, see if you can help me out.. thank you soo much for your time, happy learning...

#include<iostream>
using namespace std;
struct student {
int rolln, s1, s2, s3, s4, id;
float per, avg, sum;
long int ph;
} a[10];
void addrecord(student a){
for(int i=0; i<10; i++){
cout<<"Enter ID of Student = ";
cin>>a[i].id;
cout<<"Enter Roll Number of Student = ";
cin>>a[i].rolln;
cout<"Enter Phone Number of Student = ";
cin>>a[i].ph;
cout<"Enter Marks in English of Student = ";
cin>>a[i].s1;
cout<"Enter Marks in Programming of Student = ";
cin>>a[i].s2;
cout<<"Enter Marks in CCN of Student = ";
cin>>a[i].s3;
cout<<"Enter Marks in DBMS of Student = ";
cin>>a[i].s4;
a[i].sum = a[i].s1+a[i].s2+a[i].s3+a[i].s4;
a[i].avg = (a[i].s1+a[i].s2+a[i].s3+a[i].s4)/4;
a[i].per = (a[i].sum/400)*100;
cout<<endl;
cout<<"---------------------------------------";
cout<<"Record Added To Database Sucessfully!!!";
cout<<"---------------------------------------";
cout<<endl;
}
}

void showrecord(student s){
cout<<"++++++++++++++++++++++++++++++++++++++++";
cout<<" Students Database ";
cout<<"++++++++++++++++++++++++++++++++++++++++";
cout<<endl;
for(int j=0; j<10; j++){
cout<<"Student ID = "<<a[j].id<<endl;
cout<<"Student Roll Number = "<<a[j].rolln<<endl;
cout<<"Student Phone Number = "<<a[j].ph<<endl;
cout<<"Student Average Marks = "<<a[j].avg<<endl;
cout<<"Student Percentage (0-100%) = "<<a[j].per<<endl;
cout<<endl;
cout<<"-------------------------------------";
cout<<"-------------------------------------";

}
}

int main(){
student a[10];
addrecord(a);
showrecord(a);
return 0;

}
Last edited on
void addrecord(student a)

should be

void addrecord(student a[10])

You can solve the rest:D
Happy coding
Topic archived. No new replies allowed.