← 返回列表

C实例 计算百分比

C实例 计算百分比 #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; }

C实例 计算百分比

#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;

}

打开资源 ↗

交流与评论