Write a program to find the sum of all elements of the array.
- #include <stdio.h>
- void main()
- {
- int arr[100];
- int i, n;
- int sum=0;
- printf("Enter the number of elements to be stored in the array : ");
- scanf("%d", &n);
- printf("Enter %d elements in the array :\n", n);
- for(i=0; i<n; i++) {
- printf("Element - %d : ", i);
- scanf("%d", &arr[i]);
- }
- for(i=0; i<n; i++) {
- sum = sum + arr[i];
- }
- printf("Sum of all elements of array = %d", sum);
- }
একটি মন্তব্য পোস্ট করুন