THE UNIVERSITY OF DODOMA
College Of Informatics and Virtual Education
NAME: Makame, Makame H REGISTRATION No: T/UDOM/2010/00410 PROGRAM: B Sc. Computer and Information Security
ASSIGNMENT NO.1
COURSE NAME: Data Structure and Organization COURSE CODE: CS 104 COUSE INSTRUCTOR: Masoud Masoud
Question: Write a program to display results of students taking five subjects.
PROGRAM #include<iostream.h> #include<conio.h> #include<cstring.h>
void main() { string subjects[6]; string names[6]; int marks[20]; int k=1;
//control inpitsfor marks
int o=1;
//control output for marks
int amnt=5;
//amount of students
int amntb=3;
//amount of subjects
names[0]="Names"; cout<<"Enter the subjects taken by the students\n"; for( int i=1; i<=amntb; i++) cin>>subjects[i]; for( int j=1; j<=amnt; j++) { if(j==1) cout<<"\nEnter the name of student\t"; else cout<<"\nEnter the name of the next student\t"; getline(cin,names[j]); cout<<"\nEnter his/her marks on corresponding subjects\n"; for(; k<=amntb*j; k++) { //(amntb*(j-1))limits the index of subjects[] to amntb cout<<subjects[(k-(amntb*(j-1)))]<<"\t"; cin>>marks[k];
cout<<endl; } } for(int l=0; l<=amnt; l++) { for(int m=l; m<=l; m++) { cout<<names[m]<<"\t"; } if(l==0) { for(int n=1; n<=amntb; n++) cout<<subjects[n]<<"\t"; cout<<endl; } else for(; o<=(amntb*l); o++) cout<<marks[o]<<"\t"; cout<<endl; } getch(); }