Professional Documents
Culture Documents
Introduction to C++
programming language
Program Life cycle
Analyze:
Define Problem
System and
Complete the
Software
documentation
Design
Choose the
Test and debug
interface
Write the
Program
variable
• a variable is a storage area in the computer's
memory.
• Every variable has:
• a name,
• a type,
• a value,
• address
• When new value is placed into a variable, it replaces
the previous value.
• Reading variables from memory does not change their
value.
Variable Name
• There are rules you should, and usually must, follow when
naming your variables.
{ )(int main
; >>cin
;<<cout
}
A First Program
#include <iostream>
using namespace std;
int main() {
// Extract length and width
cout << "Rectangle dimensions: ";
float Length;
float Width;
cin >> Length >> Width;
cout << "Area = " << Area << " = Length "
<< Length << " * Width " << Width << endl;
return 0;
}
The if/else Selection
Structure
int mark;
cout <<“Enter your mark”;
Cin>> mark;
char grade;
if (mark>90)
grade='A';
else if (mark>80)
grade='B';
else if (mark>70)
grade='C';
else if (mark>60)
grade=‘D';
else
grade='F';
Equality operators
= == x == y x is equal to y
!= x != y x is not equal to y
Switch Statement
Example
1 2 3 4 6 7 8 9 10
Used continue to skip printing the value 5