Showing posts with label CPP. Show all posts
Showing posts with label CPP. Show all posts

Sunday, March 12, 2017

Intro to C++ Part 12

  • How Do I Start a Program? 


  1.  Identify inputs and outputs.
  2. Understand what you asked for ( Ask Questions ).
  3. Break the program down. // Functions
  4. into steps, writing each step in pseudocode English.
  5.  Replace each pseudocode step with C++ codes.

Intro to C++ Part 9

A statement

is an instruction that is executed and typically
updates some variable (called a side effect).
An expression is something that is evaluated and does not update
a variable (typically)
int x,y;
y=5;
x = (y = y+2);

What is x going to be?

Evaluate 5+2 and store 7 in y
2 Above also resulted in evaluating the y=y+2 expression, to 7.
→ store 7 in x.
It is very bad Idia to do so
Assignment Statements
In an assignment statement, first the expression on the right-hand side of the equal sign is
evaluated and then the variable on the left-hand side of the equal sign is set equal to this value.
SYNTAX
Variable = Expression;
EXAMPLES
distance = rate * time;
count = count + 2;

Saturday, March 11, 2017

Intro to C++ Part 3

Programming Language history:

The original Big 4:
1954 Fortran (Formula Translator)
1958 LISP (List Processing Language)
1958 Algol (Algorithm Language)
1959 COBOL (Common Business Oriented Language)
1970s Kernighan and Richie (K&R) develop an operating system (Unix) and a language (C) targeted at efficient and low-level applications.
1983 Stroustrup creates C++,
  

Intro to C++ Part 2

What is Programming? 

Simply writing codes; however, the codes should have a correct format:

  • Readability - Writeability 
  • Documentation: Header comments for each module,
  • meaningful inline comments for code 
  • Correctness 

A C++ Sample code with a fine format:

#include <iostream> // Including Input Output library

using namespace std; // using namespace" is a command, and "std" is a little something called a library. "std" stands for "standard".

int main() // Main function
{
    cout << "Hello world!" << endl; // Will be print Hello World on screen. 
    return 0;// Main function always return 0.
}

Digital Design Part 3

4th→ assembler translates it to the machine language. 1.6 [20] <§1.6> Consider two different implementations of the same instru...