Why other compliers not showing precise output?

Why when I use our DEV C++ on home, it shows the real output like the total deduction, total netpay, etc. But when I use the DEV C++ complier on school, it shows random outputs.

Here's 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


struct employees{
    char name[50];
    
}s[50];


int Equation(int NetPay[],int GrossPay[], int TotDed[])
 {
 	int i;
 	int TotalNetPay;
 	int TotalGrossPay;
 	
 	for (i=0; i<3; i++)
 {
 	TotalNetPay = TotalNetPay + NetPay[i];
 	TotalGrossPay = TotalGrossPay + GrossPay[i];
}

 printf("Total NetPay: %d \n", TotalNetPay);
 printf("Total GrossPay: %d \n", TotalGrossPay);
 }
    




int func(int RelationShipStatus[],int q[], int w[])
{

 
	int GrossPay[50];
	int SSS[10];
	int WT[10];
	int PF[10];
	int PH[10];
	int NetPay[10]; 
	int TotDed[10];
    int i;
    int TotalDeduction;
    
	

	for(i=0; i<3; i++)
	{
	GrossPay[i]=q[i]*w[i];
    SSS[i]=GrossPay[i]-300;
	WT[i]=SSS[i]-500;
    PF[i]=WT[i]-200;
	PH[i]=PF[i]-100;
	}	
	


for (i=0; i<3; i++)
{
	switch(RelationShipStatus[i])
	{
	
	case 1:
    NetPay[i]= PF[i] - 500;
    TotDed[i]= 300+500+200+100+500+500;
    break;
    
    case 2:
    NetPay[i] =  PF[i]  - 450;
    TotDed[i] = 300+500+200+100+500+450;
	break;
	
	case 3:
	NetPay[i]= PF[i] - 400;
	TotDed[i]= 300+500+200+100+500+400;
	break;
	
	case 4:
	NetPay[i]= PF[i]- 300;
	TotDed[i]= 300+500+200+100+500+300;
	break;
    }
    
 }
 
 for (i=0; i<3; i++)
 {
 	TotalDeduction = TotalDeduction + TotDed[i];
 }
 
    printf("\t \t \t \t \t \t \t%20s \n","LPU Corporation");
    printf("\t \t \t \t \t \t \t%20s \n","Payroll Report");
    printf("\t \t \t \t \t \t \t%20s \n","Month of Febuary 2016");
    printf("\t \t \t \t \t \t \t%20s \n","(10 Employees)");
    printf(" \t %s/ %20s/ %20s/ %20s/ %20s/ %20s/ %20s/ %20s \n","Emp No.","Emp Name.","Hrs Worked","Hourly Rate","Gross Pay","Tax Ex code.","Total Ded.","Net pay");
for(i=0; i<3; i++)
     {
     printf("\t %d       %20s  %20d  %20d  %20d  %20d  %20d  %20d  \n",i,&s[i].name,q[i],w[i],GrossPay[i],RelationShipStatus[i],TotDed[i],NetPay[i]);
     }
     printf("\n");
     printf("Grand Totals: \n");
     Equation(NetPay, GrossPay, TotDed);
     printf("Total Deduction: %d \n",TotalDeduction);
 }
 
 
    
    int main()
    {
    	int RelationShipStatus[50];
    	int q[10];
	    int w[10];
	    int i;
	    int TotalHrsWrkd;
	    int TotalHrsRte;
	    
    	 for (i=0; i<3; i++)
{
	printf("Enter your name Emp No.%d: \n",i); 
   	gets(s[i].name);
   	 
}
    
	

    	for (i=0; i<3; i++)
    	{
    	printf("Enter hours worked Emp No.%d: \n",i);
	    scanf(" %d", &q[i]);
	    printf("Enter hourly rate Emp No.%d: \n",i);
	    scanf(" %d", &w[i]);
        printf("Emp No.%d \n",i);
	    printf("Choose 1 if you are Single. \n");
	    printf("Choose 2 if you are Head of the family. \n");
	    printf("Choose 3 if you are Married with 2 dependents. \n");
	    printf("Choose 4 if you are Married with 3 dependents \n");
    	scanf("%d", &RelationShipStatus[i]);
        }
        
        
    	func(RelationShipStatus, q, w);
    	
    	for(i=0; i<3; i++)	
    	{
    	TotalHrsWrkd = TotalHrsWrkd + q[i];
	    TotalHrsRte = TotalHrsRte + w[i];
		}
		
		printf("Total Hours Worked: %d \n", TotalHrsWrkd);
		printf("Total Hourly Rate: %d", TotalHrsRte);
		
	    
 }
Last edited on
Topic archived. No new replies allowed.