where we have to use {} and at what disgance ...??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

where we have to use {} and at what disgance ...???

tHis is the problem

15th Mar 2017, 6:29 PM
Muhammad Moin
Muhammad Moin - avatar
2 Answers
+ 2
Curly brackets are used to create a block of code. This is mostly used in if statements in which you have more that one instructions to execute, loops and so on. Basically there is not a limit to how much you can use but the compiler will expect a " } " for each " { " you declare, which basically means that blocks of code can't be left open.
23rd Mar 2017, 3:22 PM
Nox Fortes
Nox Fortes - avatar
+ 1
We use {} to define the body of a function. It can be used at any distance i. e. it is not customary to write the { in the next line. You can continue it in the same line.
27th Mar 2017, 7:43 AM
Vishnu ks
Vishnu ks - avatar