+ 2

What is output and why??

Int x; x=2,3,4,5; Printf("%d",x);

24th Jun 2019, 3:17 AM
Gaurav Rawat
Gaurav Rawat - avatar
5 Antworten
+ 10
If you lowercased your I the answer is 2. What happens is that when you declare integers like: int a, b, c, d; a, b, c, d are all integer typed. What if you want to assign a value? int a=8, b, c, d=5; Now what if you forget to store some variables? int x = 2, {y=} 3, {z=} 4; Here, imagine inserting a fictitious y and z and this whole statement makes sense. Seriously that 3, 4, 5 are all useless and you don't need them.
24th Jun 2019, 3:28 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 13
Think you've encountered this question in the C challenges. Think you've got the answer but there was another question which is similar and I wanted to discuss it with you. {Int x; x=(2,3,4,5); Printf("%d",x);} Unlike your question this program outputs : 5 Because braces have been used.
25th Jun 2019, 12:12 PM
Manoj
Manoj - avatar
+ 8
It would be preferred if you ran these sort of codes in a C compiler.
24th Jun 2019, 3:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
First come first serve buddy 2 is first line hence it has the right to be the answer of this snippet 😅
25th Jun 2019, 1:59 AM
John Dhinakar
John Dhinakar - avatar
+ 3
First assignment i.e. 2 will be output. You could give a try by yourself in c compiler.
24th Jun 2019, 3:26 AM
Sachin Artani
Sachin Artani - avatar