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 reserved words?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What will the preprocessor do for a program?
Why do we need functions in c?
What is time complexity c?
Are the variables argc and argv are always local to main?
What does typeof return in c?
Can you write the function prototype, definition and mention the other requirements.
Explain what does the format %10.2 mean when included in a printf statement?
Explain how can you avoid including a header more than once?
Why is sprintf unsafe?
What is the benefit of using #define to declare a constant?
Explain output of printf("Hello World"-'A'+'B'); ?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What is graph in c?