Introduction:
- C ++ language proposed by Bjarne Stroustrup in 1979 at Bell Labs.
- It is middle level object-oriented programming language.
- Initially, the C++ language is called ‘C with classes’ later changed to c++.
- The
C++ extension is .cpp
- C ++ is bottom up approach.
- It is used to create system applications like games, drivers, and so on.
https://www.whereisstuff.com/2020/09/why-you-should-keep-learning-cc.html
https://www.whereisstuff.com/2020/09/why-c-language-is-better-than-c.html
Why c++ is required?
- The C++ program is updated versions of C language.
- Bjarne Stroustrup wanted an efficient and flexible language similar to C that also provided high-level features for program developers.
- In C language graphics does not support in the program, for the reason for C++ found.
https://www.whereisstuff.com/2020/09/why-c-language-is-better-than-c.html
Basic
structure of C++:
Syntax:
Example:
Program
explanation:
- # - It’s called pre-processor and used to replace the values in variables.
- include - It’s used to adding header files and user programs.
- iostream.h - Standard input and output stream header file(it holds cout and cin of library files).
- conio.h - Stands for console input and output header file(used in old MS-DOS compilers to create text user interfaces and it holds clrscr() and getch() libraries).
- void main() - Main part.
- int – Datatype.
- a,b,c – Variables.
- clrscr() – Refresh output screen.
- cout – Used to display the user entered details.
- \n – It is used to go to next line(enter process in keyboard)on the output screen.
- cin – Used to get the value from the user and put it into the memory location.
- c=a+b – Addition process and stored result in c variable.
- getch() – Used to hold the output screen and wait until the user gives any type of input(i.e until the user press any key).
Output:
Output
process in the backend:
Output
backend process explanation:
Step 1: Write source code that is your
program (refer above example program).
Step 2: Pre-processor.
- For example,
- a and b value is 10 and 4 then pre-processor replace the values.
- cin<<10<<4;
Step 3: Complier (convert the English
language to machine level language).
- To check the error and convert machine-level code (i.e. 0’s and 1’s).
Step 4: Assembler.
- After checking an error then it shows on screen.
- So we want to convert machine level language to human-readable language. (0’s and 1’s to normal text).
Step 5: loader and linker.
- Adding header files and pre-processor program.
Step 6: Final output.
Note:
Class and user define function will
deeply discuss.
No comments:
Post a Comment