To create a prompt that instructs an AI model to generate the classic "Hello World" program in all programming languages it can handle, you should structure the prompt to be clear, specific, and inclusive of the desired output format. Here's how you could define it:
Prompt Definition:
"Generate the classic 'Hello World' program in all programming languages you support. For each language, provide the specific and standard code snippet that outputs 'Hello World' to the console or equivalent output method. Include the language name as a header for each example. If there are multiple common ways to write 'Hello World' in a language, provide the most widely recognized version."
Example Output Structure:
1. Python
print("Hello World")
2. JavaScript
console.log("Hello World");
3. Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
4. C
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
5. C++
#include <iostream>
int main() {
std::cout << "Hello World" << std::endl;
return 0;
}
... (and so on for other languages)
Key Elements of the Prompt:
- Clarity – Explicitly asks for "Hello World" in all supported languages.
- Specificity – Requests the "classic" or most standard version.
- Structure – Encourages a clean, labeled output for readability.
- Flexibility – Allows the model to include variations if necessary (e.g., different Python versions).
Alternative (More Concise) Prompt:
"List the 'Hello World' program in every programming language you know, with the language name as a header for each example."
This ensures the AI provides a broad and structured response while minimizing ambiguity. Would you like any refinements based on a specific use case?