// Variable declarations and types
rakho age = 25;
rakho name = "Ahmed";
rakho is_married = jhoot;
rakho children = khali;
// Increment and decrement operators
age++;
age--;
// Compound assignment operators
age += 5;
age -= 3;
age *= 2;
age /= 2;
// Control flow: if, else, and, not
agar(age > 30 aur na is_married) {
bolo("You are over 30 and not married");
} warna {
agar(age > 25 aur is_married) {
bolo("You are married and in your late twenties");
} warna {
bolo("You are young and single.");
}
}
// Loop: while, for, break, continue
rakho i = 0;
jabtak(i < 10) {
i++;
bolo("Current value of i: " + str(i));
}
har(rakho i = 0; i < 5; i++) {
bolo("Looping, iteration: " + str(i));
}
// Classes: constructor, inheritance
jamat Person{
banao(name, age) {
yeh.name = name;
yeh.age = age;
}
introduce() {
bolo("My name is " + yeh.name + " and I am " + str(yeh.age) + " years old.");
}
}
jamat Student shamil Person {
banao(name, age, grade) {
asli.banao(name, age);
yeh.grade = grade;
}
introduce() {
asli.introduce();
bolo("I am a student in grade " + str(yeh.grade) + ".");
}
}
rakho person = Person("Khalid", 28);
person.introduce();
rakho student = Student("Layla", 17, 12);
student.introduce();