A Very Big Sum in C Program
ADVERTISEMENTS
A very big sum in c program.
In this article, you will learn how to make a very big sum in c program.
Example
Enter the size of array::
5
1000000001 1000000002 1000000003 1000000004 1000000005
Big Sum = 5000000015
You should have knowledge of the following topics in c programming to understand this program:
- C
main()
function - C
printf()
function
Source Code
// A Very Big Sum in C Program
#include <stdio.h>
int main() {
int s = 0;
printf("Enter the size of array::\n");
scanf("%d", &s);
long arr[s], sum=0;
int i=0;
while (i<s) {
scanf("%ld", &arr[i]);
sum += arr[i];
i++;
}
// It will return the final output
printf("\nBig Sum = %ld\n", sum);
return 0;
}
Output
Enter the size of array::
5
1000000001 1000000002 1000000003 1000000004 1000000005
Big Sum = 5000000015
Explanation
In this given program we have taken the inputs size of the array 5
and the array's elements 1000000001, 1000000002, 1000000003, 1000000004, 1000000005
. Then we make a sum of each element of the array.
After the whole calculation above program will return the 5000000015
output of the program.