Syntax in Progr
Syntax in Progr
What is Syntax?
What is Syntax?
Correct syntax ensures that the program can be run without any
errors. If the syntax rules are not followed correctly, the computer
will not be able to execute the commands in the program.
2. Code Validation
1. Use of Indentation
python
Copy code
if x > 10:
2. Writing Functions
python
Copy code
def greet(name):
print(f”Hello, {name}!”)
3. Use of Looping
The syntax for repeating or looping in Python can use for or while.
Here is a simple example of Python syntax for using a for loop:
python
Copy code
for i in range(5):
print(i)
javascript
Copy code
console.log(message);
In the above example, let is used to declare a variable, and
console.log is used to output the value of the variable to the
console.
cpp
Copy code
#include <iostream>
int main() {
return 0;
}
php
Copy code
<?php
?>
Conclusion
meilina eka
Previous
Email: [email protected]
Links
Applying
Giving
Careers
FIND US ON MAP