My coding doesn't work

I couldn't find why my code isn't working. When i run it pops up tell me enter the number after that is print out not correct number. Please tell me what wrong with my code.
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
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>


using namespace std;
struct Student
{
	int num1,Score;
};
void process(Student Temp);

int main()
{	Student Temp;
	int a;
	cout << "Enter your number: ";
	cin >> Temp.num1;
	if(Temp.num1 > 2)
	{
		 process(Temp);
	}
	return 0;
}

void process(Student Temp)
{	
	Temp.Score += Temp.num1;
	cout << "your score: " << Temp.Score << endl;
}
It looks like you haven't initialized Temp.Score.

Try the following:

1
2
3
4
5
int main()
{	Student Temp;
        Temp.Score = 0; // <- initialize Temp.Score here
	int a;
	cout << "Enter your number: ";
Topic archived. No new replies allowed.