๐Ÿ”’ 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
  • 374
    Views
  • 1
    Participants
Last reply from:
velvetred

Online now

Members online
991
Guests online
1,057
Total visitors
2,048

Forum statistics

Threads
2,276,161
Posts
28,967,972
Members
1,231,145
Latest member
kennethCASTRO2012
Back
Top