DEV Community

Cover image for DAY 1 OF LEARNING C++
Pranav Madhavan
Pranav Madhavan

Posted on • Updated on

DAY 1 OF LEARNING C++

INTRODUCTION TO C++

Image description

  • A Program is a Set of Instructions that tells computer what to do in order to come up with a solution to a particular program. Programs are written using a programming language. There are two major types of programming languages: low-level languages and high-level languages.

Low-Level Languages

  • A low-level language is a programming language that provides little or no abstraction of programming concepts and is very close to writing actual machine instructions.

Eg : Machine Language , Assembly Language.

  • Machine language, or machine code, is the only language that is understood by the computer, and it does not need to be translated. It is in binary numbers (1s' and 0s'). A program instruction in machine language may look something like this:

Image description

-Assembly Language is the first step to improve programming
structure and make machine language more readable by humans. An
assembly language consists of a set of symbols and letters.

A translator is required to translate the assembly language to
machine language called the 'assembler.'

High-Level Languages

  • It allow programmer's to write instructions in a language that
    is easier to understand.

  • Compiler : It converts HLL(High Level Language) to
    machine language in one run.

  • Interpreter : It converts HLL(High Level Language) to
    machine language Line by Line.

  • Source Code : Program written in High Level Language.

  • Object Code : Program in Machine Language.

Algorithm

  • Algorithm is Step by Step procedure to write a Program.

Flowchart

  • Graphical representation of algorithm is known as Flowchart.

Image description

Pseudocode

  • Pseudocode is a method of describing computer algorithm using a combination of natural language and programming.

Example 1
Write a flowchart and pseudocode for finding the sum of 2
numbers.

PSEUDOCODE

1. Start
2. Input 2 numbers ʹ number1 and number2
3. Add number1 and number2 to find sum
4. Print sum
5. End

Enter fullscreen mode Exit fullscreen mode

FLOWCHART

Image description

Example 2
Write a flowchart and pseudocode to find maximum of three given
numbers.

PSEUDOCODE

1. Start
2. Read three numbers ʹ a,b and c
3. Compare a and b, if a > b
      Compare a and c, if a > c
                 Print a
      Else
                 Print c
    Else
      Compare b and c, if b > c
                 Print b
      Else
                 Print c
4. End

Enter fullscreen mode Exit fullscreen mode

FLOWCHART

Image description

Example 3
Write a flowchart and pseudocode to find a number is prime or not.

PSEUDOCODE

1. Start
2. Read a number n
3. Initialise divisor = 2
4. Repeat till divisor < n
     If n is divisible by divisor
         Print ͞Non-Prime͟
         End
     Else
         divisor = divisor + 1
5. Print ͞Prime͟
6. End

Enter fullscreen mode Exit fullscreen mode

FLOWCHART

Image description

Example 3
Write a flowchart and pseudocode to find a number is prime or not.

PSEUDOCODE

1. Start
2. Read a number n
3. Initialise divisor = 2
4. Repeat till divisor < n
     If n is divisible by divisor
         Print ͞Non-Prime͟
         End
     Else
         divisor = divisor + 1
5. Print ͞Prime͟
6. End

Enter fullscreen mode Exit fullscreen mode

FLOWCHART

Image description

Example 4
Write a flowchart and pseudocode to find sum of n natural
numbers.

PSEUDOCODE

1. Start
2. Read a number n
3. Repeat the following till n becomes equal to 0
                        Add n in sum
                        Decrement n
4. Print sum
5. End

Enter fullscreen mode Exit fullscreen mode

FLOWCHART

Image description

*************** THANK YOU ALL FOR READIND **********************

@pranvmadhavan1

INSTAGRAM : @_pra.n.v

Top comments (0)