Haval1

Question 3

Jan 19th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include"stdafx.h"
  2. #include "string"
  3. #include <iostream>
  4. /*
  5. create a strcutre for student including (name ,satge, degree1,degree2)
  6. define 5 structure and find average for every student
  7. */
  8. using namespace std;
  9. struct student {
  10.     int stage, degree1, degree2;
  11.     string name;
  12. };
  13. int main()
  14. {
  15.     student std[5];
  16.     int i, av[5], sum[5];
  17.     for (size_t i = 0; i < 5; i++)
  18.     {
  19.         cout << "Name : ";
  20.         cin >> std[i].name;
  21.         cout << "Stage : ";
  22.         cin >> std[i].stage;
  23.         cout << "Degree 1 : ";
  24.         cin >> std[i].degree1;
  25.         cout << "Degree 2 : ";
  26.         cin >> std[i].degree1;
  27.         sum[i] += std[i].degree1 + std[i].degree2;
  28.     }
  29.     for (size_t i = 0; i < 5; i++)
  30.     {
  31.         av[i] = sum[i] / 2;
  32.         cout << "Av for student [ " << i + 1 << " ] :" << av[i] << endl;
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment