Skip to content

Examples

Rajesh Gautam edited this page Jun 12, 2026 · 1 revision

Examples

Hello World

pcType{"Hello, World!"}\

Greeting with Input

pcAsk{"What is your name? "}\
pcType{"Hello, " + input{ans} + "!"}\

Variables and Math

var{a, 10}\
var{b, 5}\
var{sum, var{a} + var{b}}\
pcType{"Sum: " + var{sum}}\

Grade Checker

var{score, 85}\

if{var{score} >= 90, then}-
    pcType{"Grade: A"}\
elif{var{score} >= 80, then}-
    pcType{"Grade: B"}\
elif{var{score} >= 70, then}-
    pcType{"Grade: C"}\
else:
    pcType{"Grade: F"}\
--\

Countdown

var{n, 10}\
while{var{n} > 0}-
    pcType{var{n}}\
    var{n, var{n} - 1}\
--\
pcType{"Blast off!"}\

For Loop — Sum

var{total, 0}\
for{i, 1, 6}-
    var{total, var{total} + var{i}}\
--\
pcType{"Sum 1–5: " + var{total}}\

Function

createFunc{greet}-
    pcType{"Hello from Curl!"}\
--\

func{greet}\

AI Chatbot (2 lines)

pcAI.context{"You are a helpful assistant."}\
pcAI.chat{""}\

AI with Variables

var{topic, "black holes"}\
pcAI.context{"You are a science teacher."}\
var{explanation, pcAI.ask{"Explain " + var{topic} + " in one sentence."}}\
pcType{var{explanation}}\

Full Program

var{name, "Ritvik"}\
var{score, 95}\

pcType{"Hello, " + var{name} + "!"}\

if{var{score} >= 90, then}-
    pcType{"Excellent!"}\
else:
    pcType{"Keep going!"}\
--\

createFunc{celebrate}-
    pcType{"Congratulations!"}\
--\

for{i, 0, 3}-
    func{celebrate}\
--\

var{reply, pcAI.ask{"Say something encouraging to " + var{name}}}\
pcType{var{reply}}\

Clone this wiki locally