8. THE PROBLEM ANALYSIS–CODING–EXECUTION CYCLE 8
Problem
Analysis
Coding
Complier
Get Results
Errors
Errors
Using Any
Programming
Language
Translate Code To
Machine
Language
10. EXAMPLE 1
Write a program to find the Area of a rectangle
The area of the Rectangle are given by the following formula:
Input : Rectangle Length , Rectangle Width.
Processing : Area = Rect Length * Rect Width.
Output : Print Out The area.
10
Area = Rect Length * Rect Width.
11. YOUR FIRST C++ PROGRAM
#include <iostream>
using namespace std;
int main()
{
// This program is written by khaled ahmed
cout << "My first C++ program." << endl;
return 0;
}
Sample Run: >>>>>
My first C++ program.
11
12. COMMENTS :
We can put comment on our programs using
// to comment a single line
// this progrm is written by khaled ahmed
/*
Mulitple Lines
*/ to comment multiple lines
/* This program is written by Khaled ahmed
On Monday 17/7/2022
*/
12
13. C++ DATA TYPES 13
char Character or small integer. 1byte
int Integer. 4bytes
bool
Boolean value. It can take one of two
values: true or false.
1byte
float Floating point number. 4bytes
double Double precision floating point number. 8bytes
long long Long Long precision biggest number. 8bytes
14. WORKING WITH VARIABLE
14
Int length ;
Int width;
Int area;
Cin>>Length;
Cin>>width;
Area = Length * width ;
Length
Width
area
5
10
50