Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include <stdio.h>
float total(float, int);

typedef struct BOOK
{
	int serial;
	char title[30];
	char author[30];
	float price[30];
	int quantity;
}BOOK;

int main()
{
	BOOK a[2];
	int x;
	float sum;
	for(x=0;x<2;x++)
	{
           printf("Please Enter Your Book Serial Number :\n");
           scanf("%d", &a[x].serial);
           printf("Please Enter Your Book Title :\n");
   	   scanf("%s", &a[x].title);
           printf("Please Enter Your Book Author :\n");
   	   scanf("%s", &a[x].author);
           printf("Please Enter Your Book Price :\n");
           scanf("%f", &a[x].price);
           printf("Please Enter Book Quantity :\n");
           scanf("%d", &a[x].quantity);
           sum = total(a[x].price, a[x].quantity);
	}
	
    printf("Your Total Is : %.2f\n",sum);
    return 0;
}

float total(float z,int y)
{
	return z*y;
}
Posted
Updated 9-Feb-14 23:17pm
v3

The type of the first parameter of the total function is float, while the type of BOOK::price is float*.

 
Share this answer
 
v2
I think you mistakenly defined price as an array.

Change

Quote:
float price[30];

to
float price;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900