Calculating a percentage without truncation

A microcontroller has checked 40 manufactured parts and accepted 25 of them. It executes this C++ fragment:


C++
int accepted = 25;
int checked = 40;
float percent = 100.0f * accepted / checked;


What value is stored in percent? Answer in percent, to one decimal place. Enter only the number.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Arduino Programming Questions: