-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallenge24_ArrayWithinStudents.sol
More file actions
35 lines (24 loc) · 1.15 KB
/
Copy pathChallenge24_ArrayWithinStudents.sol
File metadata and controls
35 lines (24 loc) · 1.15 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
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
// Array within Students
// Task Create a structure -> struct Student { string name; uint256[3] marks; }
// Create two functions a) 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. b) get() - To get the name,marks in maths,marks in science and marks in english of the student. Note - Function will be public.
// You can do this :)
contract ArrayWithinStudents {
struct Student {
string name;
uint256 marksInMaths;
uint256 marksInScience;
uint256 marksInEnglish;
}
Student student;
function set(string memory _nameOfStudent,uint256 _marksInMaths,uint256 _marksInScience,uint256 _marksInEnglish) public {
student.name=_nameOfStudent;
student.marksInMaths=_marksInMaths;
student.marksInScience=_marksInScience;
student.marksInEnglish=_marksInEnglish;
}
function get() public view returns(string memory, uint256,uint256,uint256){
return(student.name, student.marksInMaths, student.marksInScience, student.marksInEnglish);
}
}