Accenture Coding Problem #5 | Adam’s Charity

Accenture logo

Today we are going to discuss some important Accenture Coding Questions and answers that has been asked in previous years for engineering Fresher hiring.

So, If you are also appearing in Accenture, then there are fair chances that you can get same difficulty level of questions in your actual exam.

Accenture logo
Accenture Coding Problem 5

Adam decides to be generous and do some charity. starting today, from day 1 until day n, he gives i^2 coins to charity on day ‘i’ (1<=i<=n).
return the total coins he would give to charity.

Input specification:
Input 1: number of days of Charity.

Output Specification:
Return the total number of coins till charity days.

Example 1:
Input 1: 2

Output: 5
There are 2 days.

Example 2:
Input 1: 3

Output: 14
There are 3 days.

Solution in C :

#include <stdio.h>
#include <math.h>

int main()
    int n;
    int sum = 0;
    for(int i=1;i<=n;i++)
        sum += pow(i,2);
    return 0;



Leave a Reply

%d bloggers like this: