help!!!!! how can i add values from a loop to a variable?

good day masters please help with my grading system program i can only input values but i cannot store it in a variable and display what i entered,i am a begginer, pleas help, i want to input more values and store it without creating more variables, example when i input quiz 90, it couts 0 or nothing happens, where is my input value stored, i am totally confused right now please help....

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
   switch(graderecord)
                                    {
                                     case '1' :
                                        fseek(fp,0,SEEK_END);
                                        another ='Y';
                                        while(another == 'Y' || another == 'y')
                                    {
                                        system("cls");
                                        cout << "Enter quiz grade : ";
                                        cin >> e.pq;
                                        fwrite(&e,recsize,1,fp);
                                        cout << "\n Add Another long quiz grade (Y/N) ";
                                        fflush(stdin);
                                        another = getchar();
                                    }
                                        break;
                                        case '2' :
                                        fseek(fp,0,SEEK_END);
                                        another ='Y';
                                        while(another == 'Y' || another == 'y')
                                    {
                                        system("cls");
                                        cout << "Enter long quiz grade : ";
                                        cin >> e.plq;
                                        fwrite(&e,recsize,1,fp);
                                        cout << "\n Add Another long quiz grade (Y/N) ";
                                        fflush(stdin);
                                        another = getchar();
                                    }
                                        break;
                                        case '3' :
                                        fseek(fp,0,SEEK_END);
                                        another ='Y';
                                        while(another == 'Y' || another == 'y')
                                    {
                                        system("cls");
                                        cout << "Enter assignment grade : ";
                                        cin >> e.pa;
                                        fwrite(&e,recsize,1,fp);
                                        cout << "\n Add Another quiz grade (Y/N) ";
                                        fflush(stdin);
                                        another = getchar();
                                    }
                                        break;
                                        case '4' :
                                        fseek(fp,0,SEEK_END);
                                        another ='Y';
                                        while(another == 'Y' || another == 'y')
                                    {
                                        system("cls");
                                        cout << "Enter project grade : ";
                                        cin >> e.pp;
                                        fwrite(&e,recsize,1,fp);
                                        cout << "\n Add Another project grade (Y/N) ";
                                        fflush(stdin);
                                        another = getchar();
                                    }
                                        break;
                                        case '5':
                                        fseek(fp,0,SEEK_END);
                                        another ='Y';
                                        while(another == 'Y' || another == 'y')
                                        fseek(fp,0,SEEK_END);
                                    {
                                        system("cls");
                                        cout << "Enter character grade : ";
                                        cin >> e.pc;
                                        fwrite(&e,recsize,1,fp);
                                        cout << "\n Add Another character grade (Y/N) ";
                                        fflush(stdin);
                                        another = getchar();
                                    }
                                        break;
                                        case '6' :
                                        fseek(fp,0,SEEK_END);
                                    {
                                        system("cls");
                                        cout << "Enter prelim grade : ";
                                        cin >> e.pg;
                                    }
                                    break;
                                    case '7':
                                    {
                                        start ();
                                    }
                                    return 0;
First thing to note is that proper formatting really helps to show the structure of a program, but improper formatting really obscures it.

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
switch( graderecord )
{
	case '1':
		fseek( fp, 0, SEEK_END );
		another ='Y';
		while( another == 'Y' || another == 'y' )
		{
			system( "cls" );
			cout << "Enter quiz grade : ";
			cin >> e.pq;
			fwrite( &e, recsize, 1, fp );
			cout << "\n Add Another long quiz grade (Y/N) ";
			fflush( stdin );
			another = getchar();
		}
		break;
	case '2':
		fseek( fp, 0, SEEK_END );
		another ='Y';
		while( another == 'Y' || another == 'y' )
		{
			system( "cls" );
			cout << "Enter long quiz grade : ";
			cin >> e.plq;
			fwrite( &e, recsize, 1, fp );
			cout << "\n Add Another long quiz grade (Y/N) ";
			fflush( stdin );
			another = getchar();
		}
		break;
	case '3':
		fseek( fp, 0, SEEK_END );
		another ='Y';
		while( another == 'Y' || another == 'y' )
		{
			system( "cls" );
			cout << "Enter assignment grade : ";
			cin >> e.pa;
			fwrite( &e, recsize, 1, fp );
			cout << "\n Add Another quiz grade (Y/N) ";
			fflush( stdin );
			another = getchar();
		}
		break;
	case '4':
		fseek( fp, 0, SEEK_END );
		another ='Y';
		while( another == 'Y' || another == 'y' )
		{
			system( "cls" );
			cout << "Enter project grade : ";
			cin >> e.pp;
			fwrite( &e, recsize, 1, fp );
			cout << "\n Add Another project grade (Y/N) ";
			fflush( stdin );
			another = getchar();
		}
		break;
	case '5':
		fseek( fp, 0, SEEK_END );
		another ='Y';
		while( another == 'Y' || another == 'y' )
			fseek( fp, 0, SEEK_END );
		{
			system( "cls" );
			cout << "Enter character grade : ";
			cin >> e.pc;
			fwrite( &e, recsize, 1, fp );
			cout << "\n Add Another character grade (Y/N) ";
			fflush( stdin );
			another = getchar();
		}
		break;
	case '6':
		fseek( fp, 0, SEEK_END );
		{
			system( "cls" );
			cout << "Enter prelim grade : ";
			cin >> e.pg;
		}
		break;
	case '7':
	{
		start();
	}
		return 0;
Is this your code?

They are using variables to store the values of input. It really isn't possible not to store the input in a variable, otherwise you can't pass it to functions and the like.

I think you need to clarify what you need help on.
Topic archived. No new replies allowed.