Your First A++ Program
Let's write your first A++ program and understand the basics of the language.
Creating a Hello World Program
Create a new file called hello.a++
:
c
// This is your first A++ program
print("Hello, World!");
Run the program:
bash
a++ hello.a++
Understanding the Program
Let's break down what's happening:
//
starts a single-line commentprint()
is a built-in function for output"Hello, World!"
is a string literal
A More Complex Example
Let's write a program that demonstrates more features:
c
// Input/Output example
string name = "Name";
print("Hello, " + name + "!");
// Variables and arithmetic
int age = 25;
float height = 1.75;
// Conditional statements
if (age >= 18) {
print("You are an adult!");
} else {
print("You are a minor!");
}
// Loops
for (int i = 1; i <= 5; i++) {
print("Count: " + i);
}
Running Programs
Command Line
bash
# Basic execution
a++ yourprogram.a++
Common Beginner Mistakes
- Forgetting semicolons
c
// Wrong
print("Hello")
// Correct
print("Hello");
- Using wrong boolean values
c
// Wrong
boolean flag = true;
// Correct
boolean flag = yup; // A++ uses yup/nope
Next Steps
Now that you've written your first programs:
- Learn about Variables and Types
- Explore Control Flow
- Master Functions
- Try the Examples