Why do we give a space after comma in printf("%d", a), why don't we write it as printf("%d",a) ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 5

Why do we give a space after comma in printf("%d", a), why don't we write it as printf("%d",a) ?

30th Sep 2019, 4:30 PM
Sk. Ahmed Razha Khan
Sk. Ahmed Razha Khan - avatar
4 Respostas
+ 8
You don't have to do it, you can cram it all together. Only it will look ugly and be hard to read. It's actually like that in real language, too: Open a novel or a newspaper article, and you will find that there are certain conventions where you put the white space. One of them being that after comma, semicolon, full stop and so on there's a space.
30th Sep 2019, 4:52 PM
HonFu
HonFu - avatar
+ 1
Similar to having extra newlines between code segments/blocks etc. It's always a balance between too much and too little whitespace.
2nd Oct 2019, 2:01 PM
Sonic
Sonic - avatar
+ 1
It's not necessary but you will be forced by some IDEs to write it in organised manner. But its up to you. As a programmer, one should focus on logics and conditions rather than worrying about some spaces. But it will definately 'Save Paper'.
2nd Oct 2019, 3:42 PM
Parampreet Rai
Parampreet Rai - avatar
+ 1
Focussing on the logics and conditions - while *reading* the code! - will be hard when it comes as an unformatted block without any whitespace.
2nd Oct 2019, 4:08 PM
HonFu
HonFu - avatar