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

Trending Topics

Online now

Members online
1,033
Guests online
1,752
Total visitors
2,785

Forum statistics

Threads
2,286,582
Posts
29,038,742
Members
1,217,057
Latest member
Hahahahahahnba2k20
Back
Top