Tuesday, March 26, 2013

C Language Example # 46 2D Array Find Sum of All Element of Array

C Language Example # 46 2D Array Find Sum of All Element of Array.

* This program calculates sum of all elements of array.

//Written by : Latest Technology Guide
//Title : C Language Example #  46 2D Array Find Sum of All Element of Array.

 
#include <stdio.h>
#include <conio.h>
void main()
{
    clrscr();
    int a[3][3],i,j,sum=0;

    printf("\n\t : Enter the value in 3 x 3 Array : \n");

    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("Enter Value of A[%d][%d] = ",i,j);
            scanf("%d",&a[i][j]);

        }

    }
    printf("\n\t :  Sum of 3 x 3 array is  : \n");

    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            sum=sum+a[i][j];
        }
    }

    printf("\n\t Sum : %5d",sum);

    getch();
}


Output:



--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 46 2D Array Find Sum of All Element of Array.

*  Program will find sum of all elements.


Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements.

1 comment:

  1. Thanks for providing right solution Example # 46 2D Array Find Sum of All Element of Array.

    ReplyDelete