Discussion :: Arrays - General Questions (Q.No.1)
|Vaishnavi said: (Aug 2, 2010)|
|When I tried the program in the compiler an error namely "invalid initialization"appeared. So the compiler has thrown an error.
Then why could not B option be the correct answer. Could anyone please explain me.
|Sundar said: (Aug 3, 2010)|
I have tested the above program in Turbo C, it crashes at run time as explained (as given in Option C).
In GCC it shows the output as '10'. Here the compiler takes care of this kind of situation (as given in Option D).
And I have tested the same concept in Java as given below:
public class Test
public static void main(String  args)
int arr = new int;
arr = 10;
System.out.print("The output is : " + arr);
It gives the following Run time error (as given in Option C):
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
Therefore, I conclude that there are more possibilities of program crash or termination. So option C is correct.
|Gajendra Gayakwad said: (Sep 3, 2011)|
|Because in c language bound checking is performed by compiler array size always be given by programmer side.|
|Raj said: (Sep 7, 2011)|
|The code which I tried in turbo C is
This program prints the output as 6.
Can anyone explain please ?
|Vishwas said: (Jan 6, 2012)|
|For character array there is an indication of end of the string by null char, but in integer array there is no such end, if there is an free space at address arr in RAM it will get allocated by value 6.|
|Cybog said: (Jul 23, 2012)|
|Even if some value is already present at that location, it will be overwritten. So if some important value like count or status is stored there, it may lead to unexpected o/p or program crash.|
|Arunesh said: (Dec 29, 2012)|
|I have tried the program but the program gives me the out put 10 .
I have tried on indiabix online compiler
please explain how?
|Swathi Gs said: (Aug 15, 2013)|
|In GCC it shows the output as '10'. Here the compiler takes care of this kind of situation (as given in Option D).
please explain this.
|Naresh said: (Nov 12, 2013)|
|What is a magic matrix?|
|Sujeet Kumar said: (Jun 16, 2014)|
|When I tried the program in the compiler an error namely "invalid initialization"appeared. So the compiler has thrown an error.|
|Priyanka Kumari said: (Sep 6, 2014)|
|I write the same program but it shows me answer 10. I executed in the compile given below and execute it it also shows result 10. Then how can we decide appropriate option? it creates ambiguity.|
|Vasuvandan said: (Sep 23, 2014)|
|Sometimes it throws error and other times it assigns value even array bound exceeds.|
|Pritam said: (Dec 20, 2014)|
|I write the same program in Turbo C and Linux. It shows me answer 10. Compiler not given any type of error. Can you explain me?|
|Difu said: (Jan 30, 2015)|
#define SQR(x) (x*x)
What is the output of this program? why not 25?
|Saloni said: (Feb 3, 2015)|
|I tried it on Turbo C and get result 10.|
|Shiva said: (Mar 21, 2015)|
|I have tried in my compiler but came out of editor? Anyone explain?|
|Nar Singh Yadav said: (Mar 22, 2015)|
|What does the following declaration means int (*ptr) ;?|
|Arockiasamy.K said: (Mar 23, 2015)|
|Answer is 11. Because the x value passed as 3+2. So, SQR(x)(x*x) change into as SQR (3+2(3+2*3+2).
So, the operator priority multiplication get the first priority.
= (3+6+2) = 11.
|Manojkumar said: (Aug 10, 2015)|
|Haritha said: (Apr 13, 2016)|
|I tried it in linux compiler it gave the output as 10.|
|Amertarasu said: (Jul 21, 2016)|
|Isn't in the case why ArrayIndexOutOfBounds Exception exists?|
|Anand Kumar said: (Oct 4, 2016)|
|I also tried and found no error, it still gave the expected output, no compilation or runtime error.|
|Priya said: (Oct 25, 2016)|
|If the number of elements exceeds the array size, where the exceeded elements will be stored exactly.
For ex: If the array size is , if i enter six elements where the sixth element is stored. Whether it overwrites the array size or it stores some other location.
|Divya said: (Jun 7, 2017)|
|On linux compiler will give some only warnings like array size is exceeded.and it will give o/p like this,
o/p:1,2 only will give.
|Rama said: (Sep 8, 2017)|
|Why we don't do this program in java?|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.