Programming Fundamentals: Structure & Syntax
Master the foundational building blocks of programming through comprehensive coverage of character sets, keywords, identifiers, constants, variables, type declarations, and pre-processor directives. This guide provides practical examples in both English and Bengali, making programming concepts accessible to a wider audience.
Character Sets: The Foundation of Code
What is a Character Set?
A character set defines the collection of valid characters that can be used in a programming language. It forms the alphabet of your code, determining what symbols, letters, and numbers are recognized by the compiler or interpreter.
Understanding character sets is crucial because it affects how you write identifiers, strings, and comments in your programs. Different programming languages support different character sets, though most modern languages use extended ASCII or Unicode.
Letters
A-Z, a-z for naming variables and functions
Digits
0-9 for numeric values and identifiers
Special Symbols
@, #, $, % and operators for programming logic
Whitespace
Spaces, tabs, newlines for code formatting
Keywords: Reserved Words in Programming
Keywords are reserved words that have special meaning in a programming language. They cannot be used as identifiers for variables, functions, or any other user-defined items because they serve specific purposes in the language syntax.
1
Language-Specific
Each programming language has its own set of keywords. For example, C uses int, float, if, while Python uses def, class, return.
2
Case-Sensitive
Most modern languages treat keywords as case-sensitive. In C++, int is a keyword but Int or INT can be used as identifiers.
3
Cannot Be Redefined
Keywords have fixed meanings and cannot be redefined or used for other purposes. Attempting to use them as identifiers will result in compilation errors.
Common Keywords (English)
  • int - Integer data type
  • float - Floating-point number
  • if - Conditional statement
  • while - Loop control
  • return - Function return
Common Keywords (Bengali)
  • পূর্ণসংখ্যা - Integer (Bengali equivalent)
  • ভাসমান - Floating-point
  • যদি - If condition
  • যতক্ষণ - While loop
  • ফেরত - Return statement
Identifiers: Naming Your Variables
Identifiers are user-defined names for variables, functions, arrays, and other program elements. They provide meaningful labels that make code easier to understand and maintain. Choosing good identifiers is a crucial skill in programming.
01
Start with Letter or Underscore
Identifiers must begin with a letter (a-z, A-Z) or an underscore (_), never with a digit
02
Use Alphanumeric Characters
After the first character, you can use letters, digits, and underscores in any combination
03
Avoid Keywords
Never use reserved keywords as identifiers - they have special meanings in the language
04
Be Descriptive
Choose meaningful names that clearly indicate the purpose of the variable or function
05
Follow Naming Conventions
Use camelCase, PascalCase, or snake_case consistently throughout your codebase
Good Examples
  • studentName
  • totalScore
  • calculateAverage
  • MAX_VALUE
Bad Examples
  • 1student (starts with number)
  • int (reserved keyword)
  • my var (contains space)
  • xyz (not descriptive)
Constants & Variables: Data Storage
Constants
Fixed values that cannot be changed during program execution. They represent data that remains the same throughout your program's runtime.
Variables
Named storage locations that can hold different values during program execution. They represent data that may change as your program runs.
Understanding the difference between constants and variables is fundamental to programming. Constants are used for values that should never change, like mathematical constants (π, e), configuration settings, or fixed limits. Variables are used for data that changes during program execution, such as user input, calculation results, or loop counters.
Constant Declaration
C uses #define or const keyword. Example: #define PI 3.14159
Variable Declaration
Specify data type and name. Example: int age; or float salary;
Assignment
Store values using assignment operator (=). Example: age = 25; or salary = 50000.0;
Constants in English
#define MAX_SIZE 100 const float PI = 3.14159; const int DAYS_IN_WEEK = 7;
Constants in Bengali
#define সর্বোচ্চ_আকার 100 const float পাই = 3.14159; const int সপ্তাহের_দিন = 7;
Type Declaration: Defining Data Types
Type declaration specifies what kind of data a variable can hold and how much memory it needs. It's one of the most important concepts in programming because it determines how data is stored in memory and what operations can be performed on it.
Integer Types
Whole numbers without decimal points. Includes int, short, long
Floating-Point
Numbers with decimal points. Includes float, double, long double
Character Types
Single characters. Includes char for letters, digits, and symbols
int - Integer
Used for whole numbers. Range typically -2,147,483,648 to 2,147,483,647. Size: 4 bytes.
float - Floating Point
Used for decimal numbers. Precision: 6-7 decimal digits. Size: 4 bytes.
double - Double Precision
Higher precision decimal numbers. Precision: 15-16 decimal digits. Size: 8 bytes.
char - Character
Single character enclosed in single quotes. Range: -128 to 127 or 0 to 255. Size: 1 byte.
English Example
int age = 25; float salary = 50000.50; double pi = 3.14159265359; char grade = 'A';
Bengali Example
int বয়স = 25; float বেতন = 50000.50; double পাই = 3.14159265359; char গ্রেড = 'A';
Pre-processor & Sample Programs
The pre-processor is a program that processes your source code before it's compiled. It handles directives that begin with # and performs text substitution, file inclusion, and conditional compilation. Understanding pre-processor directives is essential for writing efficient and maintainable code.
#include
Includes header files in your program. Example: #include <stdio.h> for input/output functions
#define
Creates macros and symbolic constants. Example: #define MAX 100 defines a constant
#ifdef / #ifndef
Conditional compilation based on whether a macro is defined or not
Complete Sample Program (English)
#include <stdio.h> #define PI 3.14159 int main() { float radius, area; printf("Enter the radius: "); scanf("%f", &radius); area = PI * radius * radius; printf("Area of circle: %.2f\n", area); return 0; }
Complete Sample Program (Bengali)
#include <stdio.h> #define পাই 3.14159 int main() { float ব্যাসার্ধ, ক্ষেত্রফল; printf("ব্যাসার্ধ লিখুন: "); scanf("%f", &ব্যাসার্ধ); ক্ষেত্রফল = পাই * ব্যাসার্ধ * ব্যাসার্ধ; printf("বৃত্তের ক্ষেত্রফল: %.2f\n", ক্ষেত্রফল); return 0; }
These sample programs demonstrate the complete structure of a C program, including pre-processor directives, variable declarations, user input, calculations, and output. The program calculates the area of a circle using the formula A = πr², showing how all the fundamental concepts work together in a practical application.
Made with