- Learn C By Examples Time
- Learn C by Examples - Home
- C Examples - Simple Programs
- C Examples - Loops/Iterations
- C Examples - Patterns
- C Examples - Arrays
- C Examples - Strings
- C Examples - Mathematics
- C Examples - Linked List

- C Programming Useful Resources
- Learn C By Examples - Quick Guide
- Learn C By Examples - Resources
- Learn C By Examples - Discussion

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program To Calculate Percentage In C

Percent means per cent (hundreds), i.e., a ratio of the parts out of 100. The symbol of percent is **%**. We generally count percentage of marks obtained, return on investment etc. Percentage can go beyond 100% also.

**For Example −** assuming that we have *total* and a *part*. So we say what *part* is what percent of *total* and should be calculated as −

**percentage = ( part / total ) × 100**

## Algorithm

Algorithm to find percentage is as follows −

START Step 1 → Collect values forpartandtotalStep 2 → Apply formula { percentage = ( part / total ) × 100 } Step 3 → Display percentage STOP

## Pseudocode

Pseudocode for the algorithm can be written as −

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

## Implementation

Implementation of this algorithm is given below −

#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

Output of the program should be −

Percentage = 93.50%

mathematical_programs_in_c.htm

Advertisements