🔒 Closed C Arrays

Status
Not open for further replies.

velvetred

Forum Veteran
Explain the solution of this program

C:
#include <stdio.h>
#define aSize 100

int main()
{
    int arr[aSize];
    int i, n, sum=0;

    
    printf("Enter size of the array: ");
    scanf("%d", &n);
    printf("\nEnter %d elements in the array: \n", n);
    for(i=0; i<n; i++)
    {
        printf("\nEnter %d element in the array: ", i+1);
        scanf("%d", &arr[i]);
    }

  
    for(i=0; i<n; i++)
    {
        sum = sum + arr[i];
    }

    printf("\nSum of all elements of array = %d \n", sum);

    return 0;
}
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 391
    Views
  • 1
    Participants
Last reply from:
velvetred

Trending Topics

Online now

Members online
1,060
Guests online
2,943
Total visitors
4,003

Forum statistics

Threads
2,332,072
Posts
29,262,329
Members
1,146,036
Latest member
wwe17k
Back
Top