+ 1

Hey can u tell me why output is 5

#include <stdio.h> int main() {int i =(1,2,3,4,5); printf("%d",i); return 0;} Thanks in advance

29th Jun 2020, 10:09 AM
Noman
Noman - avatar
4 Respuestas
+ 4
Yes I can with use of google 😂: '()' operator has higher precedence than '='. So , firstly, bracket operator is evaluated. '()' operator is operated from left to right. but it is always the result of last that gets assigned. https://stackoverflow.com/questions/17251584/difference-between-int-i-1-2-3-and-int-i-1-2-3-variable-declaration-with
29th Jun 2020, 10:22 AM
Alexander Thiem
Alexander Thiem - avatar
+ 2
Intially i=1then it changes to 2,then3,then4,then 5. So at last ,last value assigned to i.but if there is no parenthesis then i=1;
17th Jul 2020, 5:02 AM
Ravi Raj Rajput
Ravi Raj Rajput - avatar