Advertisement
mehedi1

Project - Ta

Sep 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main() {
  4.     FILE *fp;
  5.     if((fp=fopen("input.txt","r"))==NULL) {
  6.         printf("Error!! Opening FIle\n");
  7.         return 1;
  8.     }
  9.     int num;
  10.     fscanf(fp, "%d", &num);
  11.     char str[25][20];
  12.     int price[25];
  13.     for(int i=1;i<=num;++i) {
  14.         fscanf(fp, "%s %d",str[i],&price[i]);
  15.     }
  16.     fclose(fp);
  17.  
  18.     for(int i=1;i<=num;++i) {
  19.         printf("\t\t\t\t\t%d. %s = %d\n", i, str[i], price[i]);
  20.     }
  21.  
  22.     int quantity[25];
  23.     for(int i=1;i<=num;++i) {
  24.         printf("Enter The Quantity of %s: ", str[i]);
  25.         scanf("%d",&quantity[i]);
  26.     }
  27.     int total = 0;
  28.     for(int i=1;i<=num;++i) {
  29.         total += price[i] * quantity[i];
  30.     }
  31.     printf("Total: %d\n", total);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement