It displays [Error] invalid operands to binary + (have 'struct bus' and 'struct bus') enter code here
struct bus
{int bus;
}b1,b2,b3;
int main()
{
printf("Enter bus fair 1");
scanf("%d", &b1.bus);
printf("Enter bus fair 2");
scanf("%d", &b2.bus);
printf("Enter bus fair 3");
scanf("%d", &b3.bus);
expenses = b1+b2+b3; 5*14*2 ;
printf("Travelling expense is; %d", expenses);
return 0;}
Did small changes, don't have much knowledge on this yet obviously.code image
Edit- It worked after changing the error line as this, but still I want to know why it didn't work in the previous code.
enter code here
expenses = (b1.bus+b2.bus+b3.bus) ;5*14*2 ;
You are trying to add
+structs, instead of numbers. You should be referring to the actual integers within the structs for the binary operation+to work. (Binary means it is an operation that takes two operands ("input values").I think you meant
Note that in your original example you were adding b1 twice.
Also, if this is a comment,
5*14*2, write//before.