🔒 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
  • 388
    Views
  • 1
    Participants
Last reply from:
velvetred

Trending Topics

Online now

Members online
1,282
Guests online
4,148
Total visitors
5,430

Forum statistics

Threads
2,308,764
Posts
29,186,948
Members
1,191,199
Latest member
Burgir_niPapot
Back
Top