C program to initialize array elements without mentioning array size and then display on screen, Also display sum of array elements


C program to initialize array elements without mentioning array size and then display on screen, Also display sum of array elements

 /*******************************************************

C program to initialize array elements without mentioning array size and then display on screen. Also display sum of array elements

******************************************************/

#include<stdio.h>

#include<conio.h>

void main()

{

    int i;

    //array initialization

    int number[]={20,40,60,48,30};

    int sum=0;

    //clrscr();

    printf("The array elements are\n");

    for(i=0;i<5;i++)

    {

        //display of array elements

        printf("%d\t",number[i]);

        //sum of array elements

        sum=sum+number[i];

        

    }

    //display sum of array elements

    printf("\nThe sum of array elements is %d\n",sum);

}


The array elements are

20 40 60 48 30

The sum of array elements is 198


टिप्पणी पोस्ट करा

0 टिप्पण्या