Breaking

Saturday 19 August 2017

Rounding Marks

                              Rounding Marks




In a college, each student receives marks M in any of the subjects in the range from 0 to 100.
- If the difference between the marks and the next multiple of 5 is less than 3, then round the marks up to the next multiple of 5.
- If the difference between the marks and the next multiple of 5 is more than or equal to 3, then leave the marks as it is.
- If the marks obtained is less than or equal to 37, then leave the marks as it is.
Input Format:
The first line will contain the value of N which represents the count of the test cases.
Next N lines will contain the marks from M(1) to M(N)
Output Format:
N lines containing the rounded marks value, one line each for the marks from M(1) to M(N)
Constraints:
2 <= N <= 100
Example Input/Output 1:
Input:
4
83
57
48
33
Output:
85
57
50
33

Code:
#include <iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char** argv)
{
int n,i,ele,mul;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>ele;
    mul=ele;
    if(ele>37)
    {
        while(mul%5!=0)
        {
                   mul++;
        }
    if(abs(ele-mul)<3)
        cout<<mul<<"\n";
    else
        cout<<ele<<"\n";
    }
    else
        cout<<ele<<"\n";
} 
}

Please do comment If u have any Queries!

1 comment:

Like