Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created September 16, 2014 17:18
Show Gist options
  • Save shohan4556/d9875dad6bf29618b14f to your computer and use it in GitHub Desktop.
Save shohan4556/d9875dad6bf29618b14f to your computer and use it in GitHub Desktop.
initilize a two-D array and sum it
#include <stdio.h>
void main()
{
int i,j,array[4][4],sum=0;
for(i=0;i<4;i++){
for(j=0;j<4;j++){
array[i][j]=j; // initializing array
}
} // end of initialoze array
for(i=0;i<4;i++){
for(j=0;j<4;j++)
sum=sum+array[i][j]; // add elements of the array
}
printf ("%d\n",sum); // prints all all element's addition
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment