what will be the output of this program?
void main()
{
int a[]={5,10,15};
int i=0,num;
num=a[++i] + ++i +(++i);
printf("%d",num);
}
Answer Posted / ricky
Garbage Value
num=a[++i] + ++i +(++i);
in this line the last i will be incremented first
so the last ++i will return 1 after that the middle ++i will return 2 now the value of i will change every where in the program now the first ++i will return 3 since the array starts with a[0] and ends at a[2] there is no a[3] and hence it will print garbage value
Is This Answer Correct ? | 5 Yes | 3 No |
Post New Answer View All Answers
What are loops in c?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
What is hashing in c language?
Write a code to generate divisors of an integer?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
Is fortran faster than c?
What is typedef?
What are the complete rules for header file searching?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
Write a program to use switch statement.
What is the difference between call by value and call by reference in c?
Explain what are the advantages and disadvantages of a heap?
How can you determine the maximum value that a numeric variable can hold?
What is hungarian notation? Is it worthwhile?
What is binary tree in c?