int main(){
int a[]={10,20,30,40};
int i=3,x;
x=1*a[--i]+2*a[--i]+3*a[--i];
printf(“%d”,x);
}
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
x=100;
initial value of i=3;
after–i=2
after–i=1
after–i=0
so the coresponding value is 30,20,10
s0 x=1*30+2*20+3*10=100
But answer is 110???
we can’t use more than one, pre or post increment in one line,according to standard its give warning when prog. compile from command “gcc -Wall que.c”.Its should as give bellow and o/p = 100;
i=3;
x = 1*a[--i];
x = x+2*a[--i];
x = x+3*a[--i];
printf(“%d\n”,x);
Thanks Vinod Khatana