-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path24Day-ArrayWithinStudents.sol
46 lines (42 loc) · 1.12 KB
/
24Day-ArrayWithinStudents.sol
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
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
contract Day6 {
struct Student {
string name;
uint256[3] marks;
}
Student student;
function set(
//Create a function set(name of student, marks in maths,marks in science,marks in english) - To set the name and marks of a student in marks array.
string memory _name,
uint256 maths,
uint256 science,
uint256 english
) public {
uint256 i = 0;
student.name = _name;
student.marks[i] = maths;
i++;
student.marks[i] = science;
i++;
student.marks[i] = english;
}
function get()
//Create two functions get() - To get the name,marks in maths,marks in science and marks in english of the student.
public
view
returns (
string memory,
uint256,
uint256,
uint256
)
{
return (
student.name,
student.marks[0],
student.marks[1],
student.marks[2]
);
}
}