Dsa
Math
Hard
Weighted Averages
You are given a list of grades along with their respective weights. Calculate the weighted average of the grades. The formula for the weighted average is the sum of each grade multiplied by its weight divided by the sum of the weights.
Input Format:
The first line contains an integer N (1 <= N <= 1000), the number of grades.
The next N lines each contain two integers: the grade (0 <= grade <= 100) and the weight (1 <= weight <= 10).
Output Format:
Print the weighted average rounded to two decimal places.
Example:
Input:
3
80 1
90 2
70 3
Output:
76.67
Key concepts
mathaveragesweighted
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now