-
Notifications
You must be signed in to change notification settings - Fork 0
/
a23.c
48 lines (40 loc) · 777 Bytes
/
a23.c
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
//IT20055080, D.M.P.U.Karunasekara, Group3.2
#include<stdio.h>
int main(void)
{
//file pointer
FILE*companyData;
//variables
int idn[10];
int i;
int car,jeep;
int t=0,c=0,j=0;
//open file
companyData=fopen("sale.dat","w");
//check availability
if(companyData==NULL)
{
printf("File cannot be open");
return -1;
}
//user input
for(i=0;i<4;i++)
{
printf("\nEnter ID number:");
scanf("%s",idn);
printf("Number of cars sold for week: ");
scanf("%d",&car);
printf("Number of jeeps sold for week: ");
scanf("%d",&jeep);
//calculatios
c=1000*car;
j=2500*jeep;
t=j+c;
printf("Total income is: %d",t);
//store in the file
fprintf(companyData,"%s %d %d %d\n",idn,car,jeep,t);
}
//file close
fclose(companyData);
return 0;
}