-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathque4.c
68 lines (61 loc) · 1.71 KB
/
que4.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
typedef struct employee
{
char name[20];
int salery;
}emp;
int main(){
emp emp1;
emp emp2;
emp emp3;
emp emp4;
emp emp5;
char s[50];
printf("Enter the name of the file you want to make to store employees salery: ");
scanf("%s",s);
printf("\n\n\n");
// first employee
printf("Enter the name of the first employee: ");
scanf("%s",emp1.name);
printf("\n");
printf("Enter the salery of first employee: ");
scanf("%d",&emp1.salery);
printf("\n");
// Second employee
printf("Enter the name of second employee ");
scanf("%s",emp2.name);
printf("\n");
printf("Enter the salery of second employee: ");
scanf("%d",&emp2.salery);
printf("\n");
// third employee
printf("Enter the name of the third employee: ");
scanf("%s",emp3.name);
printf("\n");
printf("Enter the salery of third employee: ");
scanf("%d",&emp3.salery);
printf("\n");
// fourth employee
printf("Enter the name of fourth employee ");
scanf("%s",emp4.name);
printf("\n");
printf("Enter the salery of fourth employee: ");
scanf("%d",&emp4.salery);
printf("\n");
// fifth employee
printf("Enter the name of fifth employee ");
scanf("%s",emp5.name);
printf("\n");
printf("Enter the salery of fifth employee: ");
scanf("%d",&emp5.salery);
printf("\n\n\n");
FILE *ef;
ef = fopen(s,"w");
fprintf(ef,"Name,Salery\n");
fprintf(ef,"%s,%d\n",emp1.name,emp1.salery);
fprintf(ef,"%s,%d\n",emp2.name,emp2.salery);
fprintf(ef,"%s,%d\n",emp3.name,emp3.salery);
fprintf(ef,"%s,%d\n",emp4.name,emp4.salery);
fprintf(ef,"%s,%d\n",emp5.name,emp5.salery);
return 0;
}