but it works perfectly fine
its not supposed to take any value greater than 5, that is made sure by the enterItems()
its when i used
for(z=0;z<=sizeof(tv)/2;z++)
it crashed just for the tv case. But if i only entered laptops and mobiles it worked perfectly fine even though they have the same semantical condition.
by the way it prints wierd characters as well (like a smiley face xD)

but it works perfectly fine
its not supposed to take any value greater than 5, that is made sure by the enterItems()

If tv[z] never takes any number greater than 5, then your loop will never exit.

What will actually happen is that, once z reaches 10, it starts reading values from memory beyond the end of the array. In other words, it's reading values that are effectively random - you can't be sure what the compiler has decided to use that memory for. Eventually, one of these values will be higher than 5 (maybe even the first of them), and the loop will exit. But it's unpredictable, and presumably, it's not the way you actually intended it to behave.

@MikeyBoy i was using the array tv[] to store the values that the user entered in the TVCHECK part in the function enterItem() so that they can be used to later to print out the items that the user bought. After the bill is printed, setDefault() changes all the variables back to 0 so that the variables can be used in the next instance (its a menu program).

OK... but I don't understand why you're comparing your loop counter variable to the values stored in tv[] to check whether to continue looping or not. How many times did you intend it to loop? When did you intend it to finish looping?

i inteded it to finish looping after all the values that the user entered. For example: if the user enters the following values
1
2
3
4
5
0 //0 does not get sent to tv[]
so therefore tv[10]={1,2,3,4,5,0,0,0,0,0} //Maybe i got the zero's wrong but you get the idea

So after 5 i want the loop to stop so that it doesnt perform it again unnecessarily .

But what you're actually doing is looping until you happen to find a number in memory that's greater than 5. That can only happen once you go past the end of your array (because you initialise all members of the array to be -1, and you only allow numbers from 1 - 5 to be entered), in which case you're in the territory of stuff you can't predict. What if the first number after the end of the array happens to be a 1? What if it happens to be -10,000?

Also, why is your option class inheriting from laptops, mobiles and television? That doesn't seem to be intuitive to me. Inheritence models an "is-a" relationship. Is it true that an "option" is a television, and is a laptops, and is a mobiles, all at the same time? Multiple inheritence is rather a, well, brave thing to attempt, unless you're absolutely sure you know what you're doing.

Yes you are right option is not always a laptop, mobile and tv but it some times is. The program allows you to buy any of the items(in any category i.e. laptop, mobile and tv) for a single bill. Im not sure if that helps you to understand why i used multiple inheritance.

Also, could you explain why multiple inheritance is a brave thing to do?