#include <iostream> using namespace std;int main(){int a,b;cout<<"enter the a and b values:";cin>>a>>b;if(a>b){cout<<"a is biggest";}else{cout<<"a is smallest";}return 0;}
(1) Creating Source code
Creating includes typing and editing the valid C++ code as per the rules followed by the C++ Compiler.
(2) Saving process:
After typing, the source code should be saved with the extension .cpp
(3) Compilation
This is an important step in constructing a program. In compilation, compiler links the library files with the source code and verifies each and every line of code. If any mistake or error is found, it will throw error message. If there are no errors then it translates the source code into machine readable object file with an extension .obj
(4) Execution
In this stage, the object file becomes an executable file with extension .exe.
Steps to create a source code:
*need for #include <iostream>
using namespace std;
Usually all C++ programs begin with include statements starting with a #. The symbol # is a directive for the pre-processor. That means, these statements #include <iostream> statement tells the compiler’s pre-processor to include the header file “iostream” in the program. The header file iostream should included in every C++ program to implement input/output functionalities.
If you fail to include iostream in your program, an error message will occur on cin and cout.
The line using namespace std; tells the compiler to use standard namespace. Namespace collects identifiers used for class, object and variables.
Every C++ program must have a main function.
The main( ) function is the starting point where all C++ programs begin their execution.
Therefore, the executable statements should be inside the main( ) function.
syntax of if else statement:
if(condition)
Explanation of if else statement:
The if else statement evaluates a condition; if the condition is true then the statement inside the if part will be executed; that is the statement inside the else part will be skipped while, if the condition evaluates to false then the statement inside else part will be executed that is the statement inside if part will be skipped.
Post your comments / questions
Recent Article
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
Related Article