Most handful description to learn basic C++ language.

Computer:

Computer is an electronic device, which is capable to accept data process it and give results.

Computer Program & Programmers:

Computer process data under the control of sequence of instructions called computer programs. Those programs guide the computer through ordered actions specified by people called computer programmers.

Computer Components:

  • Hardware

The term hardware refers to the physical components of your computer.

  • Software

The programs that run on a computer are referred to as software. Software is any set of instructions that tells the hardware what to do and how to it.

Computer Organization:

  • Input Unit “Receiving” section

It obtains information (data and computer programs) from input devices and places it in other units for processing.

Data is a collection of facts about something. It could be a collection of numbers, letters, dates, images and sound. Data becomes information when it is put into context (i.e. given meaning).

Data and instructions are performed by the CPU.

A CPU is the computer system’s brain that can transfer data from input devices into useful information. It only does what it is told to do by the following instructions. For example a bar code number is just data on its own. So it the product name, image and price. But this data becomes meaningful information when the data is put together. When barcode is scanned, we can find out what item it is, what it looks, and how much it will cost.

  • Output Unit “Shipping” section

It takes information that computer has processed and place it on output device to make it available for use outside the computer.

  • Memory Unit “warehouse” section

The memory unit is the principal storage of the computer. All the data and instructions that the computer needs at a moment are stored here. A computer memory unit is the storage where data and instructions go when entered into the computer. The data and instruction need to be stored so that they’ll be available when required and can be used repeatedly without having to enter them each time through an input unit.

Primary storage (also known as main memory or internal memory), often referred to simply as memory, is the only one directly accessible to the CPU. The CPU continuously reads instructions stored there and executes them as required. This led to modern random-access memory (RAM). It is small-sized, light, but quite expensive at the same time. (The particular types of RAM used for primary storage are also volatile, i.e. they lose the information when not powered).

  • Arithmetic Logic Unit “manufacturing” section

It performs calculations, such as addition, subtraction, multiplication and division. It also contains the decision mechanisms that allow the computer, for example, to compare two items from the memory unit to determine whether they’re equal.

  • Central Processing Unit

This “administrative” section coordinates and supervises the operation of the other sections. The CPU tells the input unit when information should be read into the memory unit, tells the ALU when information from the memory unit should be used in calculations and tells the output unit when to send information from the memory unit to certain output devices.

To see how registers, memory, and second storage all work together, let us use the analogy of making a salad. In our kitchen we have:

  • a refrigerator where we store our vegetables for the salad;
  • a counter where we place all of our veggies before putting them on the cutting board for chopping;
  • a cutting board on the counter where we chop the vegetables;
  • a recipe that details what veggies to chop;
  • The corners of the cutting board are kept free for partially chopped piles of veggies that we intend to chop more or to mix with other partially chopped veggies.
  • a bowl on the counter where we mix and store the salad;
  • Space in the refrigerator to put the mixed salad after it is made.

The process of making the salad is then: bring the veggies from the fridge to the counter top; place some veggies on the chopping board according to the recipe; chop the veggies, possibly storing some partially chopped veggies temporarily on the corners of the cutting board; place all the veggies in the bowl to either put back in the fridge or put directly on the dinner table.

The refrigerator is the equivalent of secondary (disk) storage. It can store high volumes of veggies for long periods of time.

The counter top is the equivalent of the computer’s motherboard – everything is done on the counter (inside the computer). The cutting board is the ALU – the work gets done there. The recipe is the control unit – it tells you what to do on the cutting board (ALU). Space on the counter top is the equivalent of RAM memory – all veggies must be brought from the fridge and placed on the counter top for fast access. Note that the counter top (RAM) is faster to access than the fridge (disk), but cannot hold as much, and cannot hold it for long periods of time. The corners of the cutting board where we temporarily store partially chopped veggies are equivalent to the registers. The corners of the cutting board are very fast to access for chopping, but cannot hold much. The salad bowl is like a temporary register, it is for storing the salad waiting to take back to the fridge (putting data back on a disk) or for taking to the dinner table (outputting the data to an output device).

Secondary Storage

 

Secondary storage (also known as external memory or auxiliary storage), differs from primary storage in that it is not directly accessible by the CPU. This is the long-term, high-capacity “warehousing” section. Programs or data not actively being used by the other units normally are placed on secondary storage devices (e.g., your hard drive) until they’re again needed, possibly hours, days, months or even years later. Information on secondary storage devices is persistent (Persistence can also mean something that lasts for a very long time.)—it’s preserved even when the computer’s power is turned off. Secondary storage information takes much longer to access than information in primary memory.

 

Bits

The smallest data item in a computer can assume the value 0 or the value 1. Such a data item is called a bit (short for “binary digit”—a digit that can assume one of two values). It’s remarkable that the impressive functions performed by computers involve only the simplest manipulations of 0s and 1s—examining a bit’s value, setting a bit’s value and reversing a bit’s value (from 1 to 0 or from 0 to 1).

 

Byte

The basic unit of information in computer storage and processing is known as Byte. One Byte consists of eight Bits i.e. 1 Byte = 8 Bits.

 

Programming Languages

Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps.

 

Machine Language

Machine language is the lowest-level programming language, Machine languages are the only languages understood by computers.

 

Why Humans Don’t Use Machine Language?

While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. Programmers, therefore, use either a high-level programming language or an assembly language.

Assembly language is a human-readable version of machine language. An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers. Assembly language programs are translated into machine language by a program called an assembler. But it is very hard to learn and even the most basic task can require a painful amount of work on the part of the programmer. Due to its hard to understand syntax and complexity, today it is being replaced by high-level languages.

 

Due to the fact that the complexity of Assembly language programming is extremely hard to learn, and written programs are hard to maintain, low-level languages often cannot be ported to another platform, because they use platform, or, rather, CPU specific instructions, thus written Assembly code for the PC isn’t portable to another platform (such as the Mac for example) without the complete rewrite of the program. Programmers were in a need for a language that could be easily understood and are portable (movable), therefore high-level languages were created. The major difference between high-level and low-level languages is the way they are written and compiled.

 

With the help of these languages one can write applications that are portable across various platforms (such as Linux or windows) and is independent of any architecture.

Sometimes abbreviated as HLL, a high-level language is a computer programming language that isn’t limited by the computer, designed for a specific job, and is easier to understand. It is more like human language and less like machine language. However, for a computer to understand and run a program created with a high-level language, it must be compiled into machine language.

Source code written in High Level Language must be translated into Object code (Machine Language code) before processing, for this purpose Language translators (Compiler or Interpreter) are used.

Compiler Language translator compiles the whole program at once.

Interpreter translates the program line by line.

 

The C Programming Language:

 

General Purpose Language a computer programming language whose use is not restricted to a particular type of computer or a specialized application.

In structured programming, the program is divided into small parts (functions) and each part performs a specific job.

 

Unstructured programming is a characterized by all the program code being present as a single continuous block whereas in Structured Programming, programmatic tasks are split into smaller sections (known as functions or subroutines) that can be called whenever they are required.

 

The purpose of structured programming is for the programmer. Knowing the only way to get to a specific line of code is by going through the lines before it is a tool we use to keep our sanity. Putting things into units such as subroutines and statements also lets us reorganize those things easier, because we can use mnemonic (memory) techniques. It lets us focus on the important part of the code that needs changing without worrying that you need to go back through all your code to hunt down under which circumstances you arrive there.

C Programming

1

 

C is a general-purpose, high-level language that was originally developed by

Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was

originally first implemented on the DEC PDP-11 computer in 1972.

In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available

description of C, now known as the K&R standard.

The UNIX operating system, the C compiler, and essentially all UNIX application

programs have been written in C. C has now become a widely used professional

language for various reasons:

  • Easy to learn
  • Structured language
  • It produces efficient programs
  • It can handle low-level activities
  • It can be compiled on a variety of computer platforms

 

 

C  is  a  general-purpose,  high-level  language  that  was  originally  developed  by Dennis  M.  Ritchie  to  develop  the  UNIX  operating  system  at  Bell  Labs.  C was originally first implemented on the DEC PDP-11 computer in 1972.

In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard.

The UNIX operating system, the C compiler, and essentially all UNIX application programs have been written in C. C has now become a widely used professional language for various reasons:

  • Easy to learn
  • Structured language
  • It produces efficient programs
  • It can handle low-level activities (Bitwise programming readily available)
  • It can be compiled on a variety of computer platforms

 

Typical C Program Development Environment

 

C systems generally consist of several parts:

  • A program development environment
  • The language
  • C Standard Library

 

Integrated Development Environments (IDE)

 

IDE are software platforms that provide programmers and developers a comprehensive set of tools for software development in a single product. IDEs commonly include text or code editors, a debugger, a compiler, build automation tools, and a Graphical User Interface builder. Many IDEs also include code completion features that intelligently complete code automatically.

 

C programs typically go through six phases to be executed

 

Phase 1: Editor or Creating a Program

Editor is a tool used to create a design code. You type a C program with the editor, make corrections if necessary, and then store the program on a secondary storage device such as a hard disk.

 

Phase 2 and 3: Preprocessing and Compiling a C Program

  • The compiler translates the C program into machine language-code (also referred to as object code).
  • In a C system, a preprocessor program executes automatically before the compiler’s translation phase begins.
  • The C preprocessor obeys special commands called preprocessor directives, which indicate that certain manipulations are to be performed on the program before compilation.
  • These manipulations usually consist of including other files in the file to be compiled and performing various text replacements.

 

Preprocessor as the name suggests means “Process it first”.

Before that, I would like to explain the three important parts that a C program is made up of in the sequence in which it is performed:
1) Pre-Processing
2) Compiling
3) Linking/assembling
.
Preprocessing in simple terms is “the process done before handing over the control to compiler”
This Preprocessing further includes tasks like
1. Ripping off Comments

  1. Macro Substitutions (Macro substitution has a name and replacement text, defined with #define directive. The preprocessor simply replaces the name of macro with replacement text from the place where the macro is defined in the source code.)

 

For example:

#define Macro Replacement Text

#define NUM int

  1. Including the Header Files

    Preprocessing commands begin with “#”

    #include is one of these preprocessing commands that Inserts a particular header from another file and pastes previously written code (from the header file) into your program (when you say stdio.h “.h” indicates it’s a header file).
    Now say printf is a function. When you use it, its code must be written somewhere so that you directly use it. “stdio.h” is a header file, where this and other similar functions are defined. stdio.h stands for standard input output header. And so you include <stdio.h> and let complier know that you will need standard input output commands and he better include the code beforehand.

  • In Phase 3, the compiler translates the C program into machine-language code.
  • A syntax error occurs when the compiler cannot recognize a statement because it violates the rules of the language. The compiler issues an error message to help you locate and fix the incorrect statement.
  • Syntax errors are also called compile errors, or compile-time errors.

 

Phase 4: Linking

 

Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the creation of an ‘object’ file. This step doesn’t create anything the user can actually run. Instead, the compiler merely produces the machine language instructions that correspond to the source code file that was compiled. For instance, if you compile (but don’t link) three separate files, you will have three object files created as output, each with the name <filename>.o or <filename>.obj (the extension will depend on your compiler). Each of these files contains a translation of your source code file into a machine language file — but you can’t run them yet! You need to turn them into executables your operating system can use. That’s where the linker comes in.

During compilation, if the compiler could not find the definition for a particular function, it would just assume that the function was defined in another file. If this isn’t the case, there’s no way the compiler would know — it doesn’t look at the contents of more than one file at a time. The linker, on the other hand, may look at multiple files and try to find references for the functions that weren’t mentioned.

 

Linking refers to the creation of a single executable file from multiple object files. After the compiler has created all the object files, another program is called to bundle them into an executable program file. That program is called a linker and the process of bundling them into the executable is called linking.

The Linker and Executables

Standard library functions like printf( ) and scanf( ) are not part of the C programming language.

For example, the compiler cannot find a spelling error in printf or scanf. When the compiler compiles a printf statement, it merely provides space in the object program for a “call” to the library function. But the compiler does not know where the library functions are—the linker does. When the linker runs, it locates the library functions and inserts the proper calls to these library functions in the object program. Now the object program is complete and ready to be executed. For this reason, the linked program is called an executable.

If the function name is misspelled, the linker will spot the error, because it will not be able to match the name in the C program with the name of any known function in the libraries.

 

Phase 5: Loading

The next phase is called loading. Before a program can be executed, the program must first be placed in memory. This is done by the loader, which takes the executable image from disk and transfers it to memory.

 

Phase 6: Execution

Finally, the computer, under the control of its CPU, executes the program one instruction at a time.

 

Problems That May Occur at Execution Time

Programs do not always work on the first try. Each of the preceding phases can fail because of various errors that we’ll discuss. For example, an executing program might attempt to divide by zero (an illegal operation on computers just as in arithmetic). This would cause the computer to display an error message. You would then return to the edit phase, make the necessary corrections and proceed through the remaining phases again to determine that the corrections work properly.

 

 

 

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.