C++ is a high-level language . It was designed and developed by Bjarne Stroustrup in 1979 at Bell Labs. C++ is an object-oriented programming language that expands and improves the C language. C++ runs on a variety of platforms, such as Windows, MAC operating systems, and UNIX versions.
C++ is a statically typed, compiled, general-purpose, case-sensitive, irregular programming language that supports procedural, object-oriented, and generic programming.
C++ is considered an intermediate-level language that combines the characteristics of a high-level language with a low-level language.
C++ was designed and developed by Bjarne Stroustrup in 1979 at Bell Labs, Mount Merry, New Jersey. C++ further expanded and refined the C language, initially named C with classes, and later renamed C++ in 1983.
C++ is a superset of C, and in fact, any legitimate C program is a legitimate C++ program.
Note: Programming languages that use static types perform type checking at compile time, not at runtime.
A C++ program can be defined as a collection of objects that interact with each other by calling each other's methods. Now let's take a brief look at what a class, an object, a method, an instant variable is.
An object has a state and a behavior. For example: the state of a dog - color, name, breed,
shake, bark, eat. An object is an instance of a class.
Classes can be defined as templates/blueprints that describe the behavior/state of an object.
Basically, a method represents a behavior. A class can contain multiple methods. You can write logic, manipulate data, and perform all actions in a method.
Each object has its own unique instant variables. The state of an object is created by the values of these instant variables.
#include <iostream>
using namespace std;
// using namespace std is the beginning of the code
int main()
{
cout << "Hello World"; // output Hello World
return 0;
}
Boolean? ? ? ?bool
Character? ? char
integer? ? ? ? ? ?int
floating-point float
Double floating-point double
Untyped void
Boolean | bool |
Character | char |
Integer | int |
Floating-point | float |
Double floating-point | double |
Untyped | void |
Note:long long's limit is bigger than long's limit than int's limit. |
//When you want to input something, you should use one of them. (sort by time spent) (from big to small)
For example, if you want to input an integer x, you can use them.
cin >> x;
scanf("%d",&x);
/*
When you input in "scanf", you should be careful, because the different type of data have different way to input.
For example, if you want to input x, if the data type of x is one of them, you should:
type way to input
1.long long scanf("%lld",&x);
2.long scanf("%ld",&x);
3.int scanf("%d",&x);
4.char scanf("%c",&x);
5.double scanf("%lf",&x);
6.float scanf("%f",&x);
7.string scanf("%s",&x);
8.Octadecimal integer scanf("%o",&x);
9.Hexadecimal integer scanf("%c",&x);
10.None scanf("%*",&x);
//If you want to output an integer x, you should use one of them.
cout<<x;
printf("%d",&x);
//Precautions of output is similar to precautions of input.