CSEN102 Introduction to Computer Science: Lecture 3

This lecture for CSEN102: Introduction to Computer Science, given by Milad Ghantous, PhD, focuses on fundamental programming concepts.


3.1 Basic Programming Concepts

Programming involves writing instructions that a computer can understand and execute to perform a specific task. To do this, we use programming languages, which have their own syntax and rules.

1. Variables:

Variables are named storage locations in a computer's memory used to hold data. The value stored in a variable can change during program execution.

Example (Conceptual):

int age;         // Declaration: 'age' is an integer variable
age = 30;        // Assignment: 'age' is now 30
float price = 99.99; // Declaration and Initialization: 'price' is a float, set to 99.99

2. Data Types:

Data types classify the kind of values that a variable can hold and the operations that can be performed on them. Common data types include:

3. Operators:

Operators are symbols that perform operations on values and variables.

4. Input and Output (I/O):

How programs interact with the user or external systems.

Example (Conceptual):

// Input
int num;
cout << "Enter a number: "; // Prompt
cin >> num; // Read input

// Output
cout << "You entered: " << num << endl;

3.2 Program Structure (Conceptual)

While specific syntax varies, most programs follow a general structure:


3.3 Error Types in Programming

Understanding different types of errors is crucial for debugging and writing robust programs.

Thank you