1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mila [183]
3 years ago
15

What is the basics of C++

Computers and Technology
1 answer:
arlik [135]3 years ago
3 0
Here are the basics of C++...

Number 1. Printing text onto the screen:
std::cout << "Your text here\n"; 
The \n creates a new line.

Number 2. Initializing variables and setting variables
There are a few different types of variables in C++...
Integers, floats, chars, and strings.
To let C++ know what type of variable you are about to create, you put the type before the variable name.

Here are some examples:
int number = 10;
float r = 2.45;
char[4] = "Code";
string name = "Bob";

Number 3. Comments

In programming comments are very useful. They help other programmers understand your code.

To make a single line comment in C++ you do this:

// your comment

To make a multi-line comment in C++ you do this:

/*
My multi-line comment here
*/

Number 4. Math

In C++ you have math operators. These operators are + - * / %
I'm pretty sure you are familiar with the first four operators. But you may not know the last one. Don't worry... I'll explain that one to you.

Addition:

std::cout << 35 + 23 // this will print out 58

Subtraction:

std::cout << 102 - 56; // this will come out as 46

Multiplication:

std::cout << 34 * 9; // product will be 306

Division:

std::cout << 164 / 4; // quotient will be 41

Modulus:

Now we get to the operator you may or may not know. The modulus.
The modulus operator gets the remainder of division of a by b.

std::cout << 10 % 4; // it will print out 2

You can even store math operations in variables...

int answer = 40 + 38;
std::cout << answer; // this will print out 78

You can even add variables...

int x = 28;
int y = 58;
int answer = 86;
std::cout << answer;
std::cout << x + y;

Number 5. Comparison Operators.

Comparison operators compare two values to see if its true or false...
These are mainly used in if statements...

Here are the comparison operators:

== Equal
!= Not equal
> Greater than
< Less than
<= Less or equal
>= Greater or equal

Number 6. If Statements

This is the structure of an if statement:

if(...){
// execute code if true
} else if(...){
// execute this block of code if first if statement was false
}else {
// execute this block of code if false
}

if(2 > 1) {
std::cout << "2 is greater than 1";
}

The code above will indeed execute. Because two is greater than 1.

Number 7. Functions

If you have a block of code that will be repeated multiple times through out your program, functions will be handy.

To make a function you must specify the type of the function. This called the return type.
Which are int (integers), floats (decimals), and string (strings).
There are more, but I decided to focus on those three.

Then you give your function a name. 

int my_function(){
// your code
}

To call a function, you simply type the name of the function with parentheses.

my_function();

To make a function with parameters, do same thing above, except in the parentheses you give your parameters.

int my_function(int x, int y){
// your code
}

As you can see, you separate the parameters with a comma.

in my_function(int x, int y){
int z = x + y;
std::cout << z; // this will print out the sum of x and y
}

To call your function with parameters, type your function name with parentheses and in the parentheses type your values.

my_function(3, 4); // this will print out 7

Also, another type of function is the void type. In int type functions, at the end of your code in the function, you should type return 0.
This allows C++ know that code wen't without any errors...

In void type function this isn't really necessary...

If you have anymore questions or you found something to be confusing or you want to learn more C++, please write me a message.



You might be interested in
Concentric circles on a disk platter where data is stored;________
bagirrra123 [75]

Answer:

Tracks

Resilient File System (ReFS)

Explanation:

  1. Concentric circles on a disk platter where data is stored is called Tracks
  2. The new file system developed for Windows Server 2012 is called Resilient File System (ReFS). It allows increased stability for disk storage and improved features for data recovery and error checking
4 0
3 years ago
____________ occurs when a provider does not support data export or when a provider's service is unavailable through others.
elixir [45]

Answer:

The correct answer to the following question will be Vendor Lock-In.

Explanation:

Vendor Lock-In: It is also known as Customer Lock-In. The Vendor Lock-In makes the costumer depends on services and products on the vendor. The costumers are not able to use another vendor without changing costs as it creates barriers.

Some ways to avoid Vendor Lock-In, these are as follows:

  • Design your application portable.
  • Keep watching vendor contracts.
  • Arrange both entry and exit with your vendor.

8 0
3 years ago
Which science topics would be suited for this organizational aid? Check all that apply.
IrinaVladis [17]

Answer:

Its A and E

Explanation:

3 0
3 years ago
Intel Centrino Technology is the combinatin of wirelesstechnology with the previous HT technology.
Kay [80]

Answer:

<u>False</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

The Intel Centrino Technology is a product marketed and sold by the tech giant Intel, which offers a combination of their Wi-Fi and WiMax technologies in a single personal laptop. It does not offer Hyper threading Technology (HT) like some of the other Intel branded CPU's. Some of the CPU's that include hyper threading are the Core I3 series.

Therefore, based on the information stated above, we can see that the statement in the question in <u>False</u>.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
2 years ago
What are the side effects of overclocking?
Oksana_A [137]

Answer:

Reduced processor lifespan, reduced fan cooler performance over time, bugs.

Explanation:

The reason is that when you overclock your processor you are increasing its base speeds in GHZ. The processor was designed to work at a determined speed, let's say 3.00 ghz. If you increase this speed to 4.00 ghz, it's not just that now it's working faster, it also draws more power from your power supply, and increases the heat that the chip is taking. Processors are designed to endure high temperatures, therefore, you will likely not see any damaged in short term, but your components life span will be severely reduced, also depending on how much you overclock the processor, and the stability of your system, you can see bugs, unexpected restarts, and strange behavior of the computer. As an example, the i5 4670k runs at 3.80 stock speed, it can reach 50 / 65 degrees under full load. If you raise the speed up to 4.5ghz it will reach 70/80 degrees, depending on your ambient temperature and other factors.

6 0
2 years ago
Other questions:
  • Technician A says that the last step in the diagnostic process is to verify the problem. Technician B says that the second step
    12·1 answer
  • Assume the existence of a class named window with functions named close and freeresources, both of which accept no parameters an
    13·1 answer
  • true or false? to change document properties, first tap or click file on the ribbon to open the properties view.
    6·2 answers
  • How much space should be allotted to park your vehicle parallel to the curb?
    5·1 answer
  • Who invented the machine known as colossus?
    9·2 answers
  • The calculation of the likelihood of an attack coupled with the attack frequency to determine the expected number of losses with
    12·1 answer
  • You are developing a system to process lists of days of the week, represented as strings. Create a function is_weekend that cons
    12·1 answer
  • All of the following are examples of service learning opportunities exept
    11·1 answer
  • If C2=20 and D2=10 what is the result of the function = mathcal I F(C2=D2,^ prime prime Ful "Open")?
    11·1 answer
  • 8. Which of the following is an output device
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!