Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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
- #include <stdio.h>
- int main() {
- float Price[50], Qty[50], Total=0;
- printf("Enter the item price and qty for each item\n");
- for(int i=0;i<5;i++){
- printf("Item %d\n",i+1);
- scanf("%f%f",&Price[i],&Qty[i]);
- }
- for(int i=0;i<5;i++){
- Total+=Price[i]*Qty[i];//price[j]=10 qty[j]=5 50
- }
- printf("Total value of purchase order %.2f\n",Total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement