![]() |
difference between some prog languages - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: difference between some prog languages (/Thread-difference-between-some-prog-languages) |
difference between some prog languages - vluzzy - 01-02-2024 Example Script: Hello, World! Python: python print("Hello, World!") JavaScript (Node.js): javascript console.log("Hello, World!"); C++: cpp #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; } Syntax Differences: Print Statement: Python: Uses print("Hello, World!"). JavaScript: Uses console.log("Hello, World!");. C++: Uses std::cout << "Hello, World!" << std::endl;. Syntax for Comments: Python: Uses # for single-line comments and ''' or """ for multi-line comments. JavaScript: Uses // for single-line comments and /* */ for multi-line comments. C++: Uses // for single-line comments and /* */ for multi-line comments. Variable Declaration: Python: Variables are dynamically typed; no explicit type declarations are needed. python message = "Hello, World!" JavaScript: Also dynamically typed. javascript var message = "Hello, World!"; C++: Requires explicit type declarations. cpp #include <string> int main() { std: ![]() return 0; } Function Definition: Python: python def greet(name): print("Hello, " + name + "!") JavaScript: javascript function greet(name) { console.log("Hello, " + name + "!"); } C++: cpp #include <iostream> void greet(std: ![]() std::cout << "Hello, " << name << "!" << std::endl; } int main() { greet("World"); return 0; } |