Advertisement
valve2

reciept

Mar 29th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | Software | 0 0
  1. //Assume we have a purchase order of 50 items. Write a C program to read two float values for each. the item price, and the quantity,store the read values inside two different arrays, Price and Qty. After reading the values into the two arrays, your progam should calculate the total value of the purchase orded
  2. #include <stdio.h>
  3. int main() {
  4. float Price[50], Qty[50], Total=0;
  5.   printf("Enter the item price and qty for each item\n");
  6.   for(int i=0;i<5;i++){
  7.     printf("Item %d\n",i+1);
  8.     scanf("%f%f",&Price[i],&Qty[i]);
  9.   }
  10.   for(int i=0;i<5;i++){
  11.     Total+=Price[i]*Qty[i];//price[j]=10  qty[j]=5 50
  12.   }
  13.  
  14.  printf("Total value of purchase order %.2f\n",Total);
  15.   return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement