int main()
{
int i ,a[i];
i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;
}
What will be output of this program?
Answers were Sorted based on User's Feedback
Answer / sachinmundhra
This will not get compile.
int i , a[i] ; // This statement will given error. Constant
expression required.
| Is This Answer Correct ? | 38 Yes | 3 No |
Answer / ramesh kumar
in array we can must enter size integer...
not as variable type like i
thats why it gives an error
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / mohammed afroz
There are compile time error in this program. Because array
can declare with a constant value.
| Is This Answer Correct ? | 7 Yes | 2 No |
Answer / vikas
Index variable of any array should be integer constant.
but in this case i is not constant so it is a error
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / rajesh
It will give segmentation fault(core dumped) - runtime error
This is not the way of declaring an array...a slight change
in program can correct it. Code below...
int main()
{
int i=0 ,a[i];
// i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;
}
output : 10
please initialise the value of i before putting it in array
a[i]..this code will work fine and will give the output as 10.
| Is This Answer Correct ? | 3 Yes | 0 No |
5. Can inline functions have a recursion?
What is the use of setfill in c++?
Is facebook written in c++?
What do you mean by translation unit?
List the advantages of inheritance.
What are the stages in the development cycle?
Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300
plz send me National informatics center paper pattern
Explain this pointer?
What is c++ flowchart?
What is #include iostream h in c++?
Declare a class vehicle and make it an abstract data type.