Skip to main content

Algorithms, Pseduocodes and FlowCharts.

Some Basic Knowledge.
C++ is a general purpose programming language, created by Bjarne Stroustrup and was firstly released in 1985. It is an extension to C language, Reason for that is if you are familiar with C language than you must be familiar with the fact that there are no classes, templates etc. present in C language. Due to which when classes are added to C language it is named as "C with Classes", but C++ is considered as default name now. 

Extra thing to remember - In "C++" the symbol "++" after C is post increment symbol and therefore, "C++" means that In C additional features are added.

Now, let's define, what are algorithms?

Algorithms are nothing but set of rules that must be followed to accomplish some task.
(Now, What that mean?😕)
let's take an example of swapping two numbers, i.e. if a = 10 and b = 20 after swapping a = 20 and b = 10.
How will you write the procedure for this?  (There are many such algorithms).
According to me following steps will be sufficient for swapping algorithm.

start:
	Take two numbers say "a" and "b"
	take an another variable say "temp"
	store a in temp
	make a equal to b
	make b equal to temp
end

Now, you must be thinking what is this, this is not looking a c++ program or any of other languages program(excluding English). Yes, this is not a pure program but this is a perfect perfect algorithm and when we write our algorithm  in this form or in a form when we don't wanted to use some particular programming language but we just wanted to present our algorithm with as much clarity as possible, we use PSEUDOCODES. I were emphasizing on this because it will help you alot in future times.

Now, let's define one more strategy for representing our Algorithms with clarity.
The name of the topic is Flow Charts.

FlowChart is a diagrammatic representation of sequence of logical steps that we require to perform the task.
Below is the flowchart for finding average of two numbers.
If you want to read more about flowcharts click here.

Finding average of two numbers.
Image source - tutorialspoint


In Next slide we will discuss about How C++ program is created, compiled and executed.

Stay tuned for the upcoming content. For any query leave a comment below.

Click the Subscribe button at the top to follow my every post regarding c++.

References -
  • w3school.

Comments

Post a Comment

Popular posts from this blog

Number Systems (Binary and Decimal Number Systems).

We are surrounded with Numbers.  For example a human being has 2 ears, 2 legs(generally) and one nose. These all are nothing but numbers. Now, one might ask why do we need to study numbers for c++ programming. Let me answer this one first. In the previous blog I discussed that every computer works on machine language i.e. 0s and 1s, everyone know 0 and 1 are numbers. Ok, done, But what the word "Systems" doing here? What is meant by number systems. Let's see. We all have studied about the numbers from 0 to 9 i.e. 0,1,2,3,4,5,6,7,9 and we very well know that every other number can be derived from these number except infinity(no one knows what's that). for example one thousand twenty two is 1022.  This number system that we have studied is called Decimal Number System.  Why, Decimal? Because this number system contains 10 different symbols.  (In Greek Deca or Deka means 10 and this words is derived from Deca/Deka). Ok, Now we know what is decimal number system and why...

Practice Problems #1.

Below are 6 problems related to arrays, decision making statements etc. No solution will be provided for these problems except Bonus Problem. Problem 1 - Your program should print  "The weather is Good" if today's temperature is greater than 20 degree and less than 25 degree,  "The weather is little cold" if today's temperature is less than 20 degree and greater than 15 degree,  "The weather is cold" if today's temperature is less than 15 degree. "The weather is little warm" if today's temperature is greater than 25 degree but less than 30 degree. "The weather is warm" if today's temperature is greater than greater than 30 degree and less than 40 degree. "The weather is really hot" if today's temperature is greater than 40 degree. Try, to not to confuse yourself with all these statements and print accordingly to the condition matching the user's input. Problem 2 - Try to create a program with foll...

C++ Built-in Data types.

Before diving into definition of various Data Types, let's first discuss something about memory. Below is the block diagram of memory(ram) where all the data is temporarily stored before execution. Memory. The lower area of this diagram is referred as Low Memory address and upper area of this diagram is referred as High Memory address. Now let's briefly discuss each of the segments, one by one. Code Segment - The segment of memory where the text or code or your file is stored temporarily is referred as code segment. For example the main function, the function that we defined etc. Data Segment  - Data segment is of two types  Initialized data segment or simply data segment - The variables that are declared and initialized in our program are stored here. Uninitialized data segment .- The variables that are just declared or have value zero and not in use are stored here. Heap - Heap is a storage where generally dynamic memory allocation takes place with the help of pointers. If...