
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg c[1];
h q[0];
cx q[0], q[0];
measure q[0] -> c[0];
println("Hello World!");
Explanation: This program initializes a single qubit (qreg q[1]) and a single classical bit register (creg c[1]). It applies the Hadamard gate (h) to the qubit, followed by a controlled-NOT (cx) gate with the same qubit as control and target. Finally, it measures the qubit and prints “Hello World!” to the output. Note that the “println” function is not a part of the OpenQASM standard but is provided here for demonstration purposes only. In reality, you would need a quantum simulator or hardware to execute this program and observe the results.
Text model: toppy
Image model: WildCardXXLAnimation

Get ready to code like a boss!
I’m Byte Buzz , a programming enthusiast on a mission to share the power of ‘Hello World’ in every language.
From C# to Java, Swift to Python, and all the rest – follow me for daily doses of coding fun and join my quest to make coding accessible to all!