02/24/2025 3
WHAT ISPROGRAMMING
• Programming is the process of creating a set of instructions that a computer can
follow to perform specific tasks or solve problems.
Or
• computer programming is the process of humans communicating with computers to
make them perform specific tasks.
• This is typically done using programming languages, which provide the syntax and
semantics for writing these instructions.
4.
02/24/2025 4
SYNTAX ANDSEMANTICS
In programming languages, syntax and semantics are two fundamental concepts that define how
programs are written and understood.
Syntax:
•Definition: Syntax refers to the set of rules that shows how code must be structured in a programming
language. It includes the correct arrangement of symbols, keywords, and punctuation.
•Examples:
•In C++, every statement must end with a semicolon (;).
•Importance: Correct syntax is essential for the code to be compiled or interpreted without errors.
•Syntax errors occur when the code violates these rules, leading to compilation or runtime errors.
5.
02/24/2025 5
SEMANTICS
•Definition: Semanticsrefers to the meaning of the code—what the statements actually do when executed.
•Examples:
•In a loop, the semantics define how many times the loop will execute based on its conditions.
•Importance: While code may be syntactically correct, it can still have semantic errors if it doesn't do what the
programmer intended. Semantic errors can lead to logical bugs that are often harder to identify than syntax errors.
6.
02/24/2025 6
KEY CONCEPTSIN PROGRAMMING
• Programming languages: tools like python, java, C++, and JavaScript that allow developers to write code.
• Algorithms: step-by-step procedures or formulas for solving problems.
• Code: the written instructions that make up a program.
• Debugging: the process of identifying and fixing errors in the code.
• Software development: the broader process that includes planning, coding, testing, and maintaining
software applications.
• Compilation/interpretation: the process of converting code written in a high-level language into machine
language that a computer can execute.
7.
02/24/2025 7
PROGRAMMING LANGUAGE
•Programming languages
These are the languages through which the human beings communicate with the computer.
• The programming languages are classified into three types:
• Low level languages.
• Middle level language
• High level language
Further more;
• Procedural Programming Languages
• OOPs
• Functional Programming Languages
• Scripting Languages
• Domain-Specific Languages (DSLs)
• etc
8.
02/24/2025 8
DIFFERENCE BETWEENPROGRAMMING AND
CODING
• Programming:
• Definition: programming is a broader process that involves designing and developing a complete
software solution. It includes problem-solving, planning, and writing algorithms.
• Components:
• Algorithm design: developing a step-by-step solution to a problem.
• Testing and debugging: ensuring the program works correctly and fixing issues.
• Documentation: writing explanations and instructions for future reference.
9.
02/24/2025 9
Coding:
• Definition:coding is the act of writing the actual lines of code in a programming language to
implement the algorithms and designs created during programming.
• Focus: it primarily concerns syntax, structure, and translating logic into a language the computer
can understand.
• Summary:
• Programming is the comprehensive process of creating software, while coding is specifically the
act of writing code. So , coding is a part of programming.
10.
02/24/2025 10
STRUCTURE PROGRAMMING
•Structured programming is a programming paradigm that emphasizes clear and logical control
flow through the use of structured controls or control instructions, such as sequences, selections,
and iterations.
• as the word suggests, it can be defined as a programming approach in which the program is made
as a single structure. It means that the code will execute the instruction by instruction one after
the other.
• the instructions in this approach will be executed in a serial and structured manner
11.
02/24/2025 11
INTRODUCTION TOC++
•C++ is a general-purpose programming language.
•Developed by Bjarne Stroustrup at Bell Labs in the late 1970s.
•An extension of the C programming language with object-oriented features.
Key Features of C++
• Object-Oriented Programming: Supports classes and objects.
• Encapsulation: Bundles data and methods that operate on the data.
• Inheritance: Enables the creation of new classes from existing ones.
• Polymorphism: Allows functions or methods to operate in different ways based on the object.
12.
02/24/2025 12
STRUCTURE OFA C++ PROGRAM
#include <iostream>
using namespace std;
int main() {
cout << "hello, world!" << endl;
return 0;
}
13.
02/24/2025 13
IOSTREAM
• Definition:iostream is a standard c++ library header that provides functionalities for input and
output (i/o) operations. It includes definitions for the standard input stream (cin), the standard
output stream (cout), and other related components.
• Purpose: It allows programmers to read from standard input (e.G., Keyboard) and write to
standard output (e.G., Console).
14.
02/24/2025 14
using namespacestd
• Definition: using namespace std; is a directive that allows the programmer to use all the
identifiers (like classes, functions, and variables) from the std namespace without having to
prefix them with std::.
• Purpose: it simplifies the code by reducing the need to repeatedly write std:: before standard
library components.
15.
02/24/2025 15
SUMMARY
• Iostream:A library for input and output operations in C++.
• Using namespace std;: a directive that allows access to standard library components without the
std:: prefix, simplifying the syntax.
16.
02/24/2025 16
CONT…
• C++uses a streams to perform input and output operations in sequential media such as the screen
or the keyboard. A stream is an object where a program can either insert or extract characters
to/from it.
STANDARD OUTPUT (cout)
STANDARD OUTPUT (cin)
17.
02/24/2025 17
STANDARD OUTPUT(COUT)
By default, the standard output of a program is the screen, and the C++ stream object defined to
access it is cout.
Cout is used in conjunction with the insertion operator, which is written as << (two "less than" signs).
Cout << "output sentence"; // prints output sentence on screen
Cout << 120; // prints number 120 on screen
Cout << x; // prints the content of x on screen
18.
02/24/2025 18
STANDARD INPUT(CIN).
• The keyword cin (pronounced “C in”) is an object, predefined in C++ to correspond to the
standard input stream. This stream represents data coming from the keyboard
• The >> is the extraction or get from operator. It takes the value from the stream object on its left
and places it in the variable on its right.
19.
02/24/2025 19
EXAMPLE
#include <iostream>
usingnamespace std;
int main ()
{
int i;
cout << "please enter an integer value: ";
cin >> i;
cout << "the value you entered is " << i;
return 0;
}