0% found this document useful (0 votes)
9 views11 pages

Programing Notes C++

The document provides an overview of key concepts in software development, including System Requirement Specifications (SRS), algorithms, flowcharts, and various programming constructs in C++. It covers data types, operators, decision structures, and the use of switch statements in programming. Additionally, it includes example C++ code snippets demonstrating these concepts.

Uploaded by

Taimoor Gill
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views11 pages

Programing Notes C++

The document provides an overview of key concepts in software development, including System Requirement Specifications (SRS), algorithms, flowcharts, and various programming constructs in C++. It covers data types, operators, decision structures, and the use of switch statements in programming. Additionally, it includes example C++ code snippets demonstrating these concepts.

Uploaded by

Taimoor Gill
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lecture 1:

SRS (System Requirement Specifications):


This is a Document that developer writes for Client. It consists of Introduction,
Functional Requirements and Non-Functional Requirements of Project.

 Functional Requirements:
These are Requirements which describe the functioning of System.

 Non-Functional Requirements:
These are requirements that system actually performs and attempt to
improve its functionality.

Algorithms:
It is a set/sequence of instruction or steps to solve a problem and produce desired
result. It is executed in sequence.

Flow Chart:
A flowchart is a diagram that depicts a process, system or computer algorithm. It
represents every step as a symbol.
Sequence Diagram:
A sequence diagram shows process interactions arranged in time
sequence. It shows sequence of a problem through a diagram. In addition,
it tells us what will software do if a step has failed.

Gantt Chart:
A Gantt chart is defined as a graphical representation of activity against time OR It
is a diagram which tells us about the timeline of the project through graph.
Example C++
#include <iostream>
using namespace std;

int main(){

cout << "Hello World";


}

Structure of the Body


Lecture 3
Data types:
A data type is an attribute associated with a piece of data that tells a computer
system how to interpret its value. OR It describes type of value stored in a
variable.
 Int (0,1,2………) Numeric or Integer
 Float (1.1, 2.4, 5.6, 7.8, ……) Decimals
 Char (‘a’, ‘x’, ……) Variable or Alphabets
 String (Player_06) Alphanumeric
 Bool (True, False)

Code 1
#include <iostream> Double quote will print the same
using namespace std; variable as it is and without quote it
will print is saved value.
int main(){
float x; Note
x = 10.23;
cout << x;
char b;
b = 'h';
cout << b;
string c;
c = "Player no 19";
cout << c;
}
Operators:
It is a character that represents a specific mathematical or logical action or
process. OR they are used to perform some operations on variables.

1. Arithmetic Operators (+, -, /, % (Mod))


2. Logical Operators (AND &&, OR ||,
NOT!)
3. Concatenation Operators (+) Arithmetic + Modulus
Single = is a assignment
4. Increment/ Decrement Operators (++, --) Operator
5. Relational Operators (<, >, <=, >=, ==, !=) == is a Equal to Operator

1.
Addition
#include <iostream>
using namespace std;

int main(){
int x,y,z;
x = 10;
y = 20;
z = x+y;
cout << z;
}
Subtraction
#include <iostream>
using namespace std;

int main(){
int x,y,z;
x = 70;
y = 30;
z = x-y;
cout << z;
}

Multiplication
#include <iostream>
using namespace std;

int main(){
int x,y,z;
x = 7;
y = 5;
z = x*y;
cout << z;
}

Division
#include <iostream>
using namespace std;

int main(){
int x,y,z;
x = 45;
y = 5;
z = x/y;
cout << z;
}

Modulus
Modulus is a remainder after
#include <iostream> Division
using namespace std;

int main(){
int x,y,z;
x = 10;
y = 5;
z = x%y;
cout << z;
}
3.
#include <iostream>
Two Different data types can never mismatch
using namespace std;
int main(){
string f_name, l_name, full_name;
f_name = "Ali";
l_name = "Raza";
full_name = f_name + l_name;
cout << full_name;
}

4.
Increment ++x is a pre-increment
#include <iostream>
x++ is a post-increment
using namespace std;

int main(){
int x;
x = 10;
x++;
cout << x;
}

Decrement --x is a pre-decrement


#include <iostream>
x-- is a post-decrement
using namespace std;

int main(){
int x;
x = 10;
x--;
cout << x;
}
Lecture 4
Decision Structure
A decision structure is a construct in a computer program that
allows the program to make a decision and change its behavior based on that
decision. OR It is used to change the flow of program according to the given
conditions.
Following are given decision structures. If a Condition becomes false it will
be ignored and remaining will be
 IF
executed.
 IF-ELSE
 Switch Same as in Example 4.1

 Nested Decision Structure

Example 4.1

By the Program By the User


#include
#include <iostream>
<iostream>
using namespace std;
using namespace
std;
int main(){
int x;
int main(){
cout << "Enter the value in
int x;
number";
x = 10;
cin >> x;
if(x > 50){
if(x > 50){
cout << "Yes";
cout << "Yes";
}
}
cout << "Here";
cout << "Here";
}
}
Example 4.2

#include <iostream>
using namespace std;

int main(){
int a,b;
cout << "Enter First Value ";
cin >> a;
cout << "Enter Second Value";
cin >> b;
if(a > b){
cout << "First Value is Greater";
}
if (a == b){
cout << "Both are Equal";
}
else{
cout << "Second Value is Greater";
}
}

Lecture 5
Switches
It is the statement that allows a variable to be tested against a list
of values for equality. The value in the switch is termed as a case, and hence
the variable being switched on is checked against the case.

If we compare more than one choices then we use switches. They are faster
then if-else because when case is true program terminates.

Example 5.1
#include <iostream>
Using namespace std;
Int main () {
Int day;
Cout << “Enter Day In Numbers”;
Cin >> day;
Switch (day) {
Case 1:
Cout << “Monday”;
Break;
Case 2:
Cout << “Tuesday”;
Break;
Case 3:
Cout << “Wednesday”;
Break;
Case 4:
Cout << “Thursday”;
Break;
Case 5:
Cout << “Friday”;
Break;
Case 6:
Cout << “Saturday”;
Break;
Case 7:
Cout << “Sunday”;
Break;
Default:
Cout<< “Enter a valid day”;
Break;
}
}

Create a code to preview Mobile Shop Store

You might also like