0% found this document useful (0 votes)
13 views1 page

PDF Q19

Uploaded by

xtcc1199
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

PDF Q19

Uploaded by

xtcc1199
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Created by: CPP Viewer

#include<stdio.h>
#include<conio.h>
int main()
{
FILE *fp;
int number, price, quantity, value, i;
float price_value;
char item[10], filename[10];
printf("Input filename: ");
scanf("%s", &filename);
fp = fopen(filename, "w");
printf("Input inventory data\n\n");
printf("Item name, Number, Price, Quantity\n");
for (i=1; i<=3; i++) {
fscanf(stdin, "%s %d %f %d", &item, &number, &price, &quantity);
fprintf(fp, "%s %d %2f %d", item, number, price, quantity);
fclose(fp);
fprintf(stdout, "\n\n");
fp = fopen(filename, "r");
printf("Item name, Number, Price, Quantity\n");
for (i=1; i<=3; i++) {
fscanf(fp, "%s %d %f %d", &item, &number, &price, &quantity);
value = price * quantity;
fprintf(stdout, "%8s %d %8.2f %8d %11.2f\n", item, number, price, quantity, value);
}
fclose(fp);
}
getch();
}

You might also like