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


Please Help Members By Posting Answers For Below Questions

What are loops in c?

554


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

671


What is hashing in c language?

619


Write a code to generate divisors of an integer?

645


In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

728






Is fortran faster than c?

587


What is typedef?

681


What are the complete rules for header file searching?

680


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

1464


Write a program to use switch statement.

662


What is the difference between call by value and call by reference in c?

621


Explain what are the advantages and disadvantages of a heap?

599


How can you determine the maximum value that a numeric variable can hold?

643


What is hungarian notation? Is it worthwhile?

703


What is binary tree in c?

626