Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void main()
- {
- float a,cno,bill;
- char nm[50],add[50],ch;
- FILE *f1,*f2;
- f1=fopen("in1.txt","r");
- if(f1==NULL)
- printf("file cannot be opened\n");
- f2=fopen("out1.txt","w");
- if(f2==NULL)
- printf("file cannot be opened\n");
- do
- {
- fscanf(f1,"%s %f %s %f",nm,&cno,add,&a);
- if(a>200)
- bill=300+((a-200)*3);
- else
- if(a>100)
- bill=100+((a-100)*2);
- else
- bill=a;
- fprintf(f2,"%s\t%.2f\t%s\t%.2f\tRs%.2f\n",nm,cno,add,a,bill);
- }while((ch=getc(f1))!=EOF);
- fclose(f1);
- fclose(f2);
- }
Advertisement
Add Comment
Please, Sign In to add comment