Breaking News

test

Breaking

Post Top Ad

Your Ad Spot

Sunday, March 8, 2020

C++ Basics Complete Tutorial for beginners | Tutorials Hub

Fourth Tutorial / Lecture (4th)

Outline of this Lecture

Watch video for more details about this Lecture:

What is IDE (Integrated Development Environment)


  • An IDE is a software that provides an environment to write, compile, debug and different other functions by using some tools​.
  • There are numbers of IDE to write C++ programs like visual studio, code block, Dev c++, turbo C++ etc.
  • For Example:
    • If we want to become a Computer Scientist we will go to that school which makes you Computer Scientist nor get admission to any other Commerce University.
    • By following above example if we want to write and run of C++ code we need to have a software that will provide write and run code facility. That software would be called IDE.

Preprocessor Directive's

  • Preprocessor directive use at top of the program to include header files using # at start. A preprocessor directive is used to process the code before compiling.
  • For example:

Header Files

  • Header files are the library files in which the definition of reserved words are saved.​
  • Syntax:​ #include<iostream>

Namespace std

  • namespace std is a standard input-output function it gives space to standard input and output. If we don’t use this statement in our program then every time we use 'cout' or 'cin' we have to write 'std::' with it .e.g std::cout.
  • Syntax: Using namespace std

What is main function?

The main function is the first function of a program which runs at first. We add many return types with the main function like int, string, float and if we don't need to return any value we use void.
Syntax: return-type main() , e.g int main(), string main(), void main().

cout Statement

'cout' is used to display any statement written in the double quote(“”) on any output device.in 'cout' C mean character and out mean output. This 'cout' statement use with an insertion operator (<<) to display the stream of character on screen.​
Syntax: cout<<“hello”;

cin Statement

'cin' is a predefined function in C++.cin is an input statement through which we give input to the program. 'cin' uses the insertion operator( >> ).​
Syntax: cin>>a;

Escape Sequence

The escape sequence is the special characters used to modify the format of the output.​
Some example of the escape sequence is as follow.​

System pause

This command pauses the screen until the user presses any key​.
Syntax:​ system(“pause”);

return 0

When we use int return type of main function then we need to use return  0. If we are not performing any mathematical operation and returning value of their result its compulsory to return 0.
Syntax: return 0;

First C++ Program

#include<iostream>​
Using namespace std;​
Int main()​
{​
cout<<“hello”<<endl;​
system(“pause”)​
return 0;​
}

No comments:

Post a Comment

Please comment if you have any queries.

Post Top Ad

Your Ad Spot

Pages