Computer Science, asked by csanchita661, 2 months ago

give me the basic thing fro c++​

Answers

Answered by bintehawahayya
0

Explanation:

basic thing for c++ is its basic syntax.

its structure is as follows:

#include <iostream>

using namespace std;

// main() is where program execution begins.

int main() {

cout << "Hello World"; // prints Hello World

return 0;

}

Answered by kishormghadi
0

Answer:

Well first, C++ is an extension to C language, it’s a Middle Level Language (combination of both High and Low level language) and is an Object Oriented Programming language.

Covering all points wouldn’t be possible so i’ll write about some of thing that you need to know about. If you are interested in learning c++, I recommend you to take an online course or you can learn with C++ primer book.

C++ fully supports object-oriented programming, including the four pillars of object-oriented development:

Encapsulation

Data hiding

Inheritance

Polymorphism

C++ program files are saved with .cpp extension.

Coming to basic syntax:

Comments:

To add comments in c++ one uses ‘//its a single line comment” or for a multiple line comment

“/* multiple

line comment*/”.

Semicolon is used to terminate a statement.

Preprocessor Directives:

They begin with #. For basics you need to know about #include

If you want to include a header file , you can simply use #inlcude<iostream>

iostream directive is most commonly used in every program for basic input output operations

Variable declaration:

Variables can be declared anywhere in the entire program, but must be declared, before they are used. Basic types availabe- int,char,bool,float, etc.

To declare variable simply first define the type then the variable name.

Eg.

int variable1;

char var2;

Cout and Cin:

Both are included in ‘iostream’ directive. Former is used for output to print on the screen and later for input. Well there are others too but these are mainly used.

Eg.

cout<<”This is a string “;

cin>>a;

Here ‘a’ is a variable

Loops:

c++ has mainly 3 three ways : for, while and do-while.

Eg.

for(int i=0;i<5;i++)

{

cout<<”Hey”;

}

It will print Hey 5 times.

int main():

It denotes where the main part of your program will begin.

Using namespace std, tells the compiler to use standard namespace. You can look for it later, i won’t go in detail right now.

To sum up, here is a sample program

// Program to print hello world

#include<iostream>

using namespace std;

int main()

{

int a;

a=3:

cout<<”hello world!”;

cout<<a;

return 0;

}

It will print —→ Hello world!3

Hope this helps you :)

Similar questions