Guest User

Thanks For Helping.

a guest
Apr 7th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. //=================================================STRUCTURES===============================================
  6.  
  7. struct DateTime
  8. {
  9.     struct Date
  10.     {
  11.         int day,month,year;
  12.        
  13.     } date;
  14.    
  15.     struct Time
  16.     {
  17.         int hour,min;
  18.        
  19.     } time;
  20. };
  21.  
  22. struct Note
  23. {
  24.     string FacultyName;
  25.    
  26.     int LevelOfStrictness;
  27.    
  28.     string Others;
  29. };
  30.  
  31. struct subject
  32. {
  33.     struct DateTime StartTime,EndTime;
  34.    
  35.     string ClassName,ClassType;
  36.    
  37.     int ThresholdPercentage,MaxPossiblePercentage;
  38.    
  39.     struct Note notes;
  40.    
  41. };
  42.  
  43. struct students
  44. {
  45.     struct subject *subjects;
  46.    
  47.     string name;
  48.    
  49.     int MaxSubjects;
  50.    
  51. } *student;
  52.  
  53. //==============================================FUNCTIONS==================================================
  54.  
  55. void PrintStudentSubjects(int x)
  56. {
  57.     int i,n;
  58.    
  59.     n=student[x].MaxSubjects;
  60.    
  61.     for(i=1;i<=n;i++)
  62.     cout<<student[x].subjects[i].ClassName<<'\n';
  63. }
  64.  
  65. //================================================MAIN=====================================================
  66.  
  67. int main(void)
  68. {
  69.     ios_base::sync_with_stdio(false);
  70.     cin.tie(NULL);
  71.    
  72.     int NStudents,Subjects,i,j;
  73.    
  74.     cout<<"Enter Number of Students:- ";
  75.    
  76.     cin>>NStudents;
  77.    
  78.     student=(struct students*)malloc(sizeof(struct students)*(NStudents+1));
  79.    
  80.     cout<<'\n';
  81.    
  82.     for(i=1;i<=NStudents;i++)
  83.     {
  84.         cout<<"Enter Number of Subjects for "<<i<<" Student:- ";
  85.        
  86.         cin>>Subjects;
  87.        
  88.         student[i].MaxSubjects=Subjects;
  89.        
  90.         student[i].subjects=(struct subject*)malloc(sizeof(struct subject)*(Subjects+1));
  91.        
  92.         cout<<'\n';
  93.        
  94.         for(j=1;j<=Subjects;j++)
  95.         {
  96.             cout<<"Enter the name of Subject "<<j<<" :- ";
  97.            
  98.             cin>>student[i].subjects[j].ClassName;                // <<<<==================Fault Here.
  99.         }
  100.        
  101.         PrintStudentSubjects(i);
  102.     }
  103.    
  104.     return 0;
  105. }
Add Comment
Please, Sign In to add comment