954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

confusing formula... help?

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...

Archer
Newbie Poster
11 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

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) ofcompileable code that demonstrates the problems is always best.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

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

Archer
Newbie Poster
11 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

>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.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You