C/C++ for Hackers: Part 7 (Variables)

2 comments
Welcome back, fellow hackers! in this part, we will be looking at what variables are, what types of variables exist, and how to create and use them.

What Are Variables?

variables are the building blocks of every software. a variable is basically a word that contains a value. we can for example make an integer variable, called a, and give it the value of 750, then when we use the variable "a", it will give the value of 750. it is easier to explain this once the code is made, so let's compile!

Step 1: Fire Up Ubuntu and Open a Text Editor.

once that is done, paste this code in your main.cpp file and compile it again using g++.
when you run the a.out file, you can see that our program prints out 750.
when you run through the code i gave you, you can see that i made comment lines to explain what i was doing. but i'll explain a little more in detail. first, we created a variable called a, which is the type of "integer", and set it's value equal to 750. when we used cout and passed it the variable name, you can see it printed out the value of the variable, and not "a".

Creating a Variable Without Specifying It's Value and Change a Variable's Value

sometimes, you want to create your variable, but assign it a value later on. this can be perfectly done! just declare your variable like this:
int a;
your variable will be created, but doesn't hold a value yet.
you can change a variables value later on too. here is an example:
a = 10;
this will change the variable a to 10. our compiler already knows it is an integer, since we already declared it earlier, but now, the variable a will have the value of 10 from that line. you can try it out yourself using cout!

Other Types of Variables

there are other types of variables too, but i will cover the basics. take note that these variables are all the same in C, except for the "string" variable, which doesn't exist in C. to use strings in C, you need to create an array of the char variable (i will cover arrays later).
we already covered integers, so i will skip those.

The Char Variable

the char variable allows us to store a single ASCII character in it (i will cover the ASCII table later). a single character is put between 2 single quotation marks.
usage example:
char a = 'F';

The String Variable

the string variable allows us to store multiple characters in it. a string is put between 2 double quotation marks.
usage example:
string bestWebsite = "Null Byte";

The Bool Variable

the bool variable can either be the value "true" or the value "false" (1 or 0). the "true" and "false" logic is called the boolean logic, which drives every digital device that exists.
usage example:
bool phoenixIsAwesome = true;

The Float Variable

the float variable is just like an integer, except that we can use numbers after the comma with it. an example:
float pi = 3.14;
that is it for this tutorial folks! in the next tutorial, we will learn how to get input from the user.
if you have any questions or problems, feel free to comment or PM me!
-Phoenix750
Next PostNewer Post Previous PostOlder Post Home

2 comments:

  1. This professional hacker is absolutely reliable and I strongly recommend him for any type of hack you require. I know this because I have hired him severally for various hacks and he has never disappointed me nor any of my friends who have hired him too, he can help you with any of the following hacks:

    -Phone hacks (remotely)
    -Credit repair
    -Bitcoin recovery (any cryptocurrency)
    -Make money from home (USA only)
    -Social media hacks
    -Website hacks
    -Erase criminal records (USA & Canada only)
    -Grade change
    -funds recovery

    Email: onlineghosthacker247@ gmail .com

    ReplyDelete
  2. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    ReplyDelete

Kategori

Kategori

MY BLOGGER. Powered by Blogger.

Recent Comments

Formulir Kontak

Name

Email *

Message *

Followers

Archives

love hacker triks

love hacker triks

Flickr

Featured Post

Popular