TCS
Company
Programming
Program
Which of the following is the correct output of the program?
#include
int main()
{
int a[5]={9,10};
printf("%d,%d",a[1],a[2]);
return 0;
}
Read Solution (Total 16)
-
- Always the array index starts at 0
int a[5]={9,10};
The above declaration ll store
a[0]=9
a[1]=10
a[2]=0
a[3]=0
a[4]=0
If u don't assign value for an index, it ll take "0" as the value...
So it ll print 10, 0
O/p: 10, 0 - 10 years agoHelpfull: Yes(39) No(0)
- 10,garbage value
- 10 years agoHelpfull: Yes(5) No(2)
- 10,0 is answer
- 10 years agoHelpfull: Yes(3) No(0)
- 9,10,0,0,0 Is the output
- 10 years agoHelpfull: Yes(2) No(3)
- SINCE a[5], where size of array is 5,a[0]=9,a[1]=5 so further all elements will contain 0 values.
ans :10,0 - 10 years agoHelpfull: Yes(1) No(0)
- 10,0 because by default a[0]=9,a[1]=10and a[2]=a[3]=a[4]=0.
- 10 years agoHelpfull: Yes(1) No(0)
- 10 AND GARBAGE VALUE
- 10 years agoHelpfull: Yes(1) No(0)
- 9 and 0
when an array is assigned with a single value the remaining positions of array is assigned the value 0
- 10 years agoHelpfull: Yes(1) No(4)
- 0,0
as the array has been partially initialized,so all the elements would be initialized as 0. - 9 years agoHelpfull: Yes(1) No(2)
- 10, 0
since a[0]=9,a[1]=10,a[2]...a[5]=0 - 9 years agoHelpfull: Yes(0) No(0)
- A[1]=10 ,A[2] =0 SINCE ARRAY HAS 5 ELEMNTS BUT GIVEN ONLY TWO VALUES A[0] A[1]
- 9 years agoHelpfull: Yes(0) No(0)
- 10 and 0 because at a[0]th position 9 is stored and in a[1] 10 is stored remaing storage space is filled with null characters.
- 7 years agoHelpfull: Yes(0) No(0)
- output : 10 0
int a[5]={9,10} if array elements are not enough declared so that rest are 0.
array start with 0 based.
a[0]=9,a[1]=10,a[2]=0. - 6 years agoHelpfull: Yes(0) No(0)
- 10 and garbage value
- 5 years agoHelpfull: Yes(0) No(0)
- Output -10,0
- 5 years agoHelpfull: Yes(0) No(0)
- 10,0
Because in this type of array intilization size is 5 and we give only 2 items so other three items will be 0. - 4 years agoHelpfull: Yes(0) No(0)
TCS Other Question