Tuesday, 24 April 2012

Starting to code 2

Hello world!

Time for a programming tutorial continuation! Last time you've learned to write "Hello world!" in your console and now I will teach you how to write a program which can add,devide or do similar mathematical operations.

First thing you have to do is open your Dev C++ and do everything like last time until you get a code looking like this:

#include <cstdlib>
#include <iostream>


using namespace std;


int main(int argc, char *argv[])
{




     system("PAUSE");
     return EXIT SUCCESS;
}

Now like last time fill it out like this:

#include <cstdlib>
#include <iostream>
#include <stdio.h>


using namespace std;


int main(int argc, char *argv[])
{
int x,y,result;

printf("Enter your first number: ");
scanf("%d",&x);
printf("\nEnter your second number: ");
scanf("%d",&y);

result=x+y;
printf("\nx+y=%d\n",result);

    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

Now you are probably wondering what the heck did I do here.Don't you worry,it's really easy to understand!Lets start:

int x,y,result;  -> Here we initialize the variables we will use in our program. int is a variable type called integer.Its a whole number and it can have values between -2,147,438,648 and 2,147,483,647.
int x Declares that we will use symbol 'x' as an integer variable.
So by that logic,the first row initializes symbols 'x,y,result' as variables that can have values between -2,147,438,648 and 2,147,483,647.

I have already explained the printf functio but ill remind you in short.It writes out(to your program console) what you write between " ".

scanf("%d",&x); -> This function scans what you write in your program console so that you can use it later.It can scan things like characters,strings or in this case integers.The %d means that what you write will be saved as an integer(which is what we need in this program).Before each variable scanned you have to put a coma( ' , ' ) and adress ( ' & ' ).So if you are scanning multiple variables with this function you have to devide them by commas and put an adress symbol in front of each(like this scanf("%d %d",&x,&y);  ).You may wonder what an adress is so I'll explain.Adress is the position of declared variable in your computer memory.Your computer has a memory(obviously) and everything stored on it has a specific location.For example if you have 20GB of memory that will be 20*2^30 Bytes of memory.Each Byte has its own location (ranging between 1 and 20*2^30).So what we are doing with this function is writing a number to a memory location occupyed by variable x or in other words x=the number scanned.

result=x+y; -> This almost doesn't need an explanation.It's a simple algerbic command which sets the result of adding x and y ( x+y ) as value of variable "result".What might confuse you is the name of the variable so I'll say right now that instead of variable "result" we could have declared variable "z" for example and write command such as "z=x+y;" which would do the same operation.

printf("x+y=%d",result); -> Now you know what printf does but this is a bit different so I'll explain in it with another function: printf("%d",result); -> What this does is write the value of variable "result" in your program console.Just like variable can be scanned it can also be written back to console."%d" as I have explained declares that the value will be in an integer form.So if you write %d anywhere between printf apostrophes the function will expect to write out a value used in program,in this case "result".So the whole function writes out "x+y= >> value of the variable "result << ".Oh you might also wonder what does "\n" mean.It simply means "next row".So whatever you were going to write out will be written in next row.

So what does the program do?It asks you to write in 2 numbers,adds them and writes out the result.Simple!

That's all for today,see you 'till next time!


Saturday, 21 April 2012

Diablo III open beta weekend

Hello world!

As some of you have heard this weekend is an Diablo III open beta weekend.As a huge Diablo III fan i can only say that Diablo III IS THE BEST DAMN GAME I'VE EVER PLAYED.It has such a huge potential and i hope Blizzard won't ruin it.Anyway,I suggest everyone to try It out this weekend as this will be your last chance till 15th May(official release).

Cya people in game!

Thursday, 19 April 2012

Educating myself :)

Hello world!

I have an exam tomorrow,it's 1 a.m. here and i just can't study without a pause so I'm posting about it here.The class is Databases and I haven't really been on lectures so I'm having a hard time here :) So far it seems easy but there's lots of commands to remember.The coding is done in SQL which is a language written for operating databases.If someone is interested I'll post a short SQL tutorial in future.Oh and also, I've heard that Database administrators are very wanted and VERY well payed so i decided to check it out more.Seems like It's true almost every company I've checked is looking for a Database expert.So if you want to make money and still haven't decided what education program to chose I'd say go for something database related.Anyways,I'll have to go back to studying now,cya all tomorrow!

Starting to code

Hello world!

In this post I will show you how to setup everything you need for programming and start coding.Programming language I will show you will be C.
So first thing you will want to do is setup your programming environment.By that i mean tidy you're room and everything around your laptop.Ok bad jokes aside,programming  environment is a program itself in which you will program.Sounds a bit complicated?Well it really isn't and you'll see that as soon as you start.I think most popular newbie programming enviornment for C would be Bloodshed Dev C++.If you dont want to install anything you can use online compilers that are just as good for beginners.Online compiler I use is Ideone.com and I would recomment it to everyone(given that you don't want to install Bloodshed Dev C++ for some reason).Once you have downloaded you're environment you have to install it and you're ready to start coding!

What you will want to do is open Dev,click "File" in the top left corner,"New","Project..." and then Console Application.Now you're ready to go!

Lets get started now!

Code should look like this:


#include <cstdlib>
#include <iostream>


using namespace std;


int main(int argc, char *argv[])
{
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


What you will write is following:
#include <cstdlib>
#include <iostream>
#include <stdio.h>


using namespace std;


int main(int argc, char *argv[])
{
    
    printf("Hello World!");
    system("PAUSE");
    return EXIT_SUCCESS;
}


Ill explain what does each line do now.

#include<stdio.h> - What this does is includes a package of functions in your program.For example if you want to do exponential function you will have to include <math.h> and for printf() we just used we need <stdio.h>.If we haven't used the include function, compiler would not recognize it as a function and will think of it as a gibberish text.It's not really important to understand it since it's not part of an actual code.




printf("Hello World!"); - Finally this is the real part of code! printf() is a function that writes anything you say to output.At end of any command in C you have to put ' ; ' as this concludes a command.Program woldn't work without it.

Rest of the program(the things you get written in beginning) aren't really neccesary to explain but I'll do it briefly for those that already know a bit about programming.#include i explained already.Other 2 includes are neccesary to run the rest of the program.
using namespace std -Explained as simply as possible,namespaces allows us to group a set of global classes,objects and/or functions under a name.




int main(int argc, char *argv[])
{
    
    XYZ


    system("PAUSE");
    return EXIT_SUCCESS;
}
int main is the main function of every program.What the program does you write in replacement of XYZ.
system("PAUSE");leave the program open after running it.
return - it concludes the main() function.





Ok so you have written everything you need to now its time to run a program!
Under "Execute" tab press "Compile".Save it anyway you want but chose to save it as C file.After that under "Execute" tab press "Run".

And there you go! You have a program that writes Hello World!

That's it for today.I'll tutor you guys further tomorrow!



Wednesday, 18 April 2012

Start programming here

Hello world!

In this post I will talk about programming.If you want to learn how to program i recommend you to read this.

Some people i know said to me that they are interested in learning how to code and then payed high amounts of money for a private school just so they could quit 1 month later.Many people start very enthusiastic so I wouldn't be surprised if you all feel the same way now.Online colleges and online schools are great.They really are great and they ARE worth the money.However,as I said,many people quit since they didnt know what's ahead of them.That's why I recommend to start learning from forums,blogs,books and cheaper resources.After a month of hard work if you still feel determined i say start taking classes.There are many good certified online degrees with which you won't have a problem finding a full-time  job.If you lack money for education you can always work as a self-employed freelancer.Most of web designers are payed extremely well for little to no work invested.Web developers,however,are a different story and I'll get to that in my future posts.

Bottom line:
Start small : read beginner tutorials and if it feels right start investing into your education because,in tech field,you can only earn money while educating.

Introduction

Hello world!

In this blog I will be reviewing things from the tech field and as well make a little programming tutorial for C.If you need any help with coding or understanding something be free to ask and I'll help you right in my next post.Also,if you want me to review something just leave your comment and I'll do it as soon as I can.

Hope you all have fun!