目录

Percentage

百分比表示百分比(百),即百分比中的百分比。百分比的符号是% 。 我们通常计算获得的商标百分比,投资回报率等。百分比也可以超过100%。

For Example −假设我们有totalpart 。 所以我们说什么parttotal百分比,应该计算为 -

percentage = ( part/total ) × 100

算法 (Algorithm)

查找百分比的算法如下 -

START
   Step 1 → Collect values for <b class="notranslate">part</b> and <b class="notranslate">total</b>
   Step 2 → Apply formula { percentage = ( part/total ) × 100 }
   Step 3 → Display percentage
STOP

伪代码 (Pseudocode)

算法的伪代码可以写成 -

procedure percentage()
   VAR value, total
   percentage = value/total * 100
   RETURN percentage
end procedure

实现 (Implementation)

该算法的实现如下 -

#include <stdio.h>
int main() {
   float percentage;
   int total_marks = 1200;
   int scored = 1122;
   percentage = (float)scored/total_marks * 100.0;
   printf("Percentage = %.2f%%", percentage);
   return 0;
}

输出 (Output)

该方案的产出应该是 -

Percentage = 93.50% 
↑回到顶部↑
WIKI教程 @2018