CodeMarshal Solution গড় নম্বর (Average Marks) - In C Progamming - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Monday, May 8, 2017

CodeMarshal Solution গড় নম্বর (Average Marks) - In C Progamming

CodeMarshal Solution গড় নম্বর (Average Marks) - In C Progamming


CodeMarshal Online Judge Solution  গড় নম্বর (Average Marks)
CodeMarshal Main Problem Link - https://algo.codemarshal.org/problems/556b5d2a9c5e850300c49cae

Problem Name: CodeMarshal Problem   গড় নম্বর (Average Marks) solution
Problem Number : CodeMarshal Problem   গড় নম্বর (Average Marks) solution
Online Judge : CodeMarshal Online Judge Solution
Solution Language : C

CodeMarshal Solution গড় নম্বর (Average Marks) - In C Progamming

CodeMarshal গড় নম্বর (Average Marks)  Solution Code in C (Basic):

Simple steps to solve:

Take number of test case first. 
Then in a for loop take again how many numbers needs to average
Then do a for loop again upto how many numbers. 
     And add the numbers to sum variable. 
     And after finishing the for loop just average = sum/how_many_numbers. That's it.


#include <stdio.h>

int main ()
{
    int i, j, n;
    scanf("%d", &n);

    for(i = 0; i < n; i++)
    {
        int sum = 0, number, average = 0, how_many_numbers;
        scanf("%d", &how_many_numbers);
        for(j = 0; j < how_many_numbers; j++)
        {
            scanf("%d", &number);
            sum += number;
        }
        average = (int) sum/how_many_numbers;
        printf("Case %d: %d\n", i+1, average);
    }

    return 0;
}

No comments:

Post a Comment