Write the function SUM_TAB which calculates the sum of the N elements of an array TAB of the type int. N and TAB are provided as parameters; the sum is returned as the result of the long type.
Difficulty level
Video recording
This exercise is mostly suitable for students
long SUM_TAB(int TAB[], int N)
{
int i = 0;
long SUM = 0;
while (i<N)
{
SUM += TAB[i];
i++;
}
return SUM;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Checking whether a given binary tree is a BST