fork download
  1. #include<iostream>
  2. using namespace std;
  3. struct student{
  4. string name;
  5. int number;
  6. int score;
  7. }st[5];
  8. int main(){
  9. int average=0;
  10. for(int i=0;i<5;i++){
  11. cout<<"Enter name ("<<i+1<<") : ";
  12. cin>>st[i].name;
  13. cout<<"Enter number : ";
  14. cin>>st[i].number;
  15. cout<<"Enter score : ";
  16. cin>>st[i].score;
  17. average = average+st[i].score;
  18. }
  19. for(int i=0;i<5;i++){
  20. cout<<"Name : "<<st[i].name<<" No."<<st[i].number<<" score = "<<st[i].score<<endl;
  21. }
  22.  
  23. cout<<"Average score is"<<average/5;
  24. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Enter name (1) : Enter number : Enter score : Enter name (2) : Enter number : Enter score : Enter name (3) : Enter number : Enter score : Enter name (4) : Enter number : Enter score : Enter name (5) : Enter number : Enter score : Name :  No.0 score = 0
Name :  No.0 score = 0
Name :  No.0 score = 0
Name :  No.0 score = 0
Name :  No.0 score = 0
Average score is0