c++ - Unexpected output printed -
I am writing a C ++ program which is necessary for: I also need to write a function to insert and display each student. The program does not work, there are no errors, so I It seems that the syntax is correct because it is compiled. Can you help me make a mistake in code? Your problem is to do with the passing of the parameter correctly and its Structures with very little to do with So when you pass a student, the function creates a After calling the same behavior call, "num" does not change to 10 after foo, because the int is passed from the value. You need to pass by context, not by value.
student names Declare a straight line of the following parameters:
- student id
- lastname
- student score [school subject K: 1
#include & lt; Iostream & gt; using namespace std; Student student {int FN; Character last name [32]; Double digits [10]; }; // y = number of school subjects; Zero determinant (student x, int y) {cout & lt; & Lt; "Insert student id:"; Cin & gt; & Gt; x.fn; Cout & lt; & Lt; "Include the student's last name:"; Cin & gt; & Gt; X.Lastname; Cout & lt; & Lt; "Insert student score:"; For (int i = 0; i & Gt; X.marks [y]; Cout & lt; & Lt; Endl; } cout & lt; & Lt; "------------------------------------" & lt; & Lt; Endl; } // v = number of students; // t = number of school subjects; Zero BookOut (student X, int v, int t) {double student average = 0; Cout & lt; & Lt; X.fn & lt; & Lt; "" & Lt; & Lt; X.Lostname & lt; & Lt; ""; For (int j = 0; j & l; t; j ++) {cout & lt; & Lt; x.marks [j] & lt; & Lt; ""; StudentAverage = StudentAverage + X. Mark [J]; } StudentAverage = StudentAverage / T; Cout & lt; & Lt; StudentAvarage; } Int main () {int num, k; Student book [100]; Cout & lt; & Lt; "Please enter the number of students:"; Cin & gt; & Gt; Number; Cout & lt; & Lt; "Please enter the amount of school subjects:"; Cin & gt; & Gt; K; {DecStudent (book [i], k) for (int i = 0; i & lt; num; i ++); } For (int i = 0; i & lt; num; i ++) {cout & lt; & Lt; "Id" & lt; & Lt; "last name"; For (int p = 0; p & lt; k; p ++) {cout & lt; & Lt; "Mark" & lt; & Lt; P & LT; & Lt; ""; } cout & lt; & Lt; "Average mark"; BookOut (book [i], number, k); } Return 0; }
zero decStudent (student X, int y)
local copy . When the decryptant () function returns, the local copy is destroyed, it is no more than this:
zero foo (int x) {x = 10; } Int main () {int num = 0; Foo (number); }
zero decStudent (student and x, int y)
Comments
Post a Comment