Is my code correct??? I would like to find the percentage like for example:

30pcs of 60pcs is 50%. But how do I code it??? I mean, how to code to get the PERCENTAGE... Is the formula:
(num/total) * 100 ??? Is this correct:

for(x=0;x<3;x++)
	{
		y=total[x];
		p[x]=((float)(y/grand))*100;
	}

I put 'y' variable to have the 'total[x]' value becuase the compiler will say that it is an error. I think it's like declaration syntax error... I forgot... Please help me.... And by the way, this is a TURBO C program...

Is my code correct??? I would like to find the percentage like for example:

30pcs of 60pcs is 50%. But how do I code it??? I mean, how to code to get the PERCENTAGE... Is the formula:
(num/total) * 100 ??? Is this correct:

for(x=0;x<3;x++)
	{
		y=total[x];
		p[x]=((float)(y/grand))*100;
	}

I put 'y' variable to have the 'total[x]' value becuase the compiler will say that it is an error. I think it's like declaration syntax error... I forgot... Please help me.... And by the way, this is a TURBO C program...

One of the most important things to include with questions like these is the data types. A small snippet (say less than 100 lines) of compileable code that demonstrates the problems is always best.

OK thanks for the info... But is code correct?

>OK thanks for the info... But is code correct?

One of the most important things to include with questions like these is the data types. A small snippet (say less than 100 lines) of compileable code that demonstrates the problems is always best.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.