-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx2.cpp
More file actions
51 lines (38 loc) · 1.46 KB
/
Ex2.cpp
File metadata and controls
51 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <conio.h> //header files
#include <iostream>
#include <iomanip>
using namespace std;
void findMarks(int t_marks1, int t_marks2, float& t_CA1, float& t_CA2); //function declaration
struct marks //create structure marks
{
int t_marks1, t_marks2;
int student;
float t_CA1, t_CA2;
};
int main() //begin main
{
marks details[5];
for (int i = 0; i < 5; i++) //begin for loop
{
cout << "Enter mark 1 for student " << i + 1 << ": "; //user input
cin >> details[i].t_marks1;
cout << "Enter mark 2 for student " << i + 1 << ": ";
cin >> details[i].t_marks2;
cout << endl;
details[i].student = i + 1;
findMarks(details[i].t_marks1, details[i].t_marks2, details[i].t_CA1, details[i].t_CA2); //calling function
} //end for loop
cout << endl;
cout << setw(10) << "student" << setw(10) << "Mark 1" << setw(10) << "Mark 2" << setw(10) << "CA 1" << setw(10) << "CA 2" << endl; //output
for (int i = 0; i < 5; i++) //begin for loop
{
cout << setw(10) << details[i].student << setw(10) << details[i].t_marks1 << setw(10) << details[i].t_marks2 << setw(10) << setiosflags(ios::fixed) << setprecision(2) << details[i].t_CA1 << setw(10) << details[i].t_CA2 << endl;
} //end for loop
(void)getchar();
//return 0;
}
void findMarks(int t_marks1, int t_marks2, float& t_CA1, float& t_CA2) //function implementation
{
t_CA1 = (t_marks1 = 20) / 100.0;
t_CA2 = (t_marks2 = 30) / 100.0;
}