439 views
0 votes
0 votes
#include<stdio.h>

int main()
{
int M = 2;
int arr[M][M] = {0}; // Trying to initialize all values as 0
int i, j;
for (i = 0; i < M; i++)
{
    for (j = 0; j < M; j++)
    printf ("%d ", arr[i][j]);
    printf("\n");
}
return 0;
}
what happen

1 Answer

0 votes
0 votes

It's not trying to initialize all variable in array , it will just initialize to first item of array arr[0][0].

just change arr[M][M]=1, and then try to print the array 

output will be like below 

1   0

0   0

Related questions

3 votes
3 votes
2 answers
1
Satwik Mishra 1 asked Aug 28, 2017
3,688 views
#include<stdio.h>int *m();void main(){int *k=m();printf("Hello");printf("%d",k[0]);}int *m(){int a ={5,8};return a;} What is the output generated?A)hello 5 8B)hello 5C)he...
0 votes
0 votes
1 answer
2
mohitbawankar asked Dec 17, 2017
371 views
#include<stdio.h>void main(){printf("Hello\b\b\b\b\b");printf("Hi!\b\b\bBye");}
0 votes
0 votes
1 answer
3
amit166 asked Nov 22, 2018
565 views
#define cube(x) x*x*xmain(){int a=3,b;b=cube(a++);printf("% d % d",a,b);}
0 votes
0 votes
1 answer
4
Sonali Rangwani asked Jan 2, 2017
426 views
would the following program give compilation error or warning? <yes/no>main() { float i=10, *j; void *k; k=&i; j=k; printf("\n%f",*j);}