Web Design,Programming,Mobile,iOS/Android,GameDev,IT Businness,eCommerce,Social Media


Tuesday, 11 February 2014

How computers do Math - Arithmetic Operators Priority in C++

In basic math algebra where we have formulas with multiple arithmetic operations taking place in C++ ( and in everyday math ) we have rules on execution priority, meaning that C++ decides which operation to do first whether its addition or multiplication. When a math formula is being executed with multiple arithmetic operations taking place multiplication and division have higher priority over all, then comes addition and substraction. In the examples below you will see how computers choose which portion of the given formula to execute first, till it completes.

If a = 5, b = 10 and c = 2 calculate the given formula below

y = 3 * a + b / c - 2

In this basic formula we have all of the arithmetic operators taking place. The very first thing computers will try to solve is multiplication as we said, so in this given example the computer will firstly calculate 3 * a then right after it will calculate b / c. Since there are no more multiplication or division operators in this formula, the computer will take the result of the first calculated portion 3 * a and the result of the second calculated portion b / c and will do addition upon these. Below i have written the steps the computer would take to solve this problem.

Step1: 3 * a = 3 * 5 = 15 

and since a = 5 we know that 3 * 5 = 15

Step2: b / c = 10 / 2 = 5

and since b = 10 and c = 2 we know that 10 / 2 = 5

Now since multiplication and division are done the computer takes the result from the first step and the result from the second step and does addition

Step3: Step1 + Step2 = 15 + 5 = 20

where Step1 + Step2 are the results from the steps respectively. And by doing addition from these two steps we achieve 20 as a result.

Step4: Step3 - 2 = 20 - 2 = 19
where Step3 is the result of the addition of Step1 and Step2. We substract 2 from Step3 and we have 18.

This is how computers break formulas into pieces and give priority based on rules to different operators. Its important to keep this in mind while programming large projects where we can have multiple calculations with different types of operators taking place, since the results can be different if we swap places of operators by mistake. And if we want precision in our calculations it is of good practice to put operations with higher priorities in parentheses. To clarify your mind take this example and translate it into actual C++ code and execute it to see the results. Do some experiments by swapping operators or adding more to see how the result will change based on priority rules.

PHP Basics - Syntax and tags

As you noticed in my first tutorial Getting Started with PHP - What is PHP ? we used opening and closing tags to start writting php commands. You will need these tags whenever you want to write php code :

  //PHP code here
So the very first thing you will do when writting php code make sure you have those tags and your actual code inside. The file where you are writing php code must have the .php extension. If you think you can write these lines in an .html file and run them properly in a browser then you are wrong. PHP files have the .php extension and thus the browser recognizes them and tells the server to execute those lines of code inside the opening and closing php tags.

Basic Printing

In the first tutorial we used to print a string on screen. To do that we used the echo command. This command is used to print and show the result of anything you want to. You can print variables ( more on variables in next tutorial ), strings and other stuff. We will get into more detail in the upcoming tutorials.

Basically what we did to print that string on screen is used the echo command and the string wrapped inside double quotes.

  echo "This is a string in double quotes to be printed on screen";
Pleace notice the semicolon in the end of the command. Since PHP is written in C and thus it has the syntax rules of C language. So every command that you enter, except keywords, functions, classes etc ( if you are familiar with these thats ok, but if not don't worry just continue we will get into those later on ), must end with a semicolon which means the end of the given command.

PHP can be mixed with html elements to stylize your strings. Take a look at this example

  echo "<h1>This is a h1 tag inside PHP</h1>";
As you can see you can wrap your strings with actual html tags inside the double quotes in an echo command, and the result will be as we would do in plain html. You may ask yourself why whould i need to put html tags inside php commands when i can just write the html tag.

Keep in mind that PHP can do a lot more than just basic printing, and when you will get into more complex stuff, like calculations data processing and other things, you will need to retrieve those results with php commands and wrapped with html tags.

Go ahead and do some experiments with the echo command and with html tags inside, like styling them with CSS or inline CSS. You will see that the result will be as you would write plain HTML. This is the basic syntax in PHP, in the upcoming tutorials we will talk more about variables.

Getting Started with PHP - What is PHP ?

PHP Logo

Hello World. This text is meant for absolute beginners in PHP. PHP is a dynamic server sided scripting language which we can use to build simple and complex websites. Dynamic means that PHP has the ability to take decisions based on different behaviors or clicks on our website, show different portions of contents, make calculations and other great stuff.

We cannot tell how much PHP is capable of in single text, rather we will focus on how to get started with things simple PHP page and show simple text on browser.

Gathering the Tools

First of all to write code you will need an IDE with syntax highlighting and indentation. Do a search on Google for PHP IDE's and you will find plenty of them. If you are a beginner then a good choice for ( if you are a windows user ) would be Notepad++ or Programmers Notepad.

As we said PHP is server sided scripting language. Server sided means that PHP code only runs in a server with appache module and packages installed. If you don't understand what this is don't worry, just go ahead and install Xampp somewhere on your computer. This program will install binaries and other stuff including PHP which we can use to actually write PHP pages. You just start the program and start the Appache module. Open your browser and in the URL bar type localhost. If you see It Work's then you have successfully installed Xampp. Congrats !

After installing this program, navigate to your installation directory and find the htdocs folder. This is the folder where we will store our projects. Create a folder inside this folder and name it whatever you like. For simple testing purpose name it mypage, or testpage.

Writing some PHP code

Now we will write simple php code to test if PHP runs perfectly. Open your favorite editor and type this line of code and save it as index.php on your early created folder in htdocs.

<?php php_info(); ?>

In your browser type localhost/testpage or whatever you named your folder. Hopefully if you did everything as told, you will see a page with your PHP configuration settings which means that we can run PHP files correctly with the help of XAMPP.

Now delete everything on your index.php file and paste this code. Again save it and navigate to localhost/testpage to see the results.

<?php echo "Hello World, This is my first PHP page. Hurray !"; ?>

Congratulations on your first successfully programmed PHP page. Please refer to online documentation to proceed and subscribe to our blog for more awesome and simple upcoming tutorials.

Monday, 10 February 2014

C++ SFML 2.0 Spritesheet Animation Class

Loading and displaying sprites with SFML 2.0 is not hard work to do, its just two functions however when it comes to animating them you will need to actually delve a little bit more deeper. I've created a basic wrapper class for SFML 2.0 which loads displays and animates spritesheets with just few lines of code.

Beginners who are finding trouble with animating their sprites could find this helpful. First of all this class implements Sprite class and Texture class, two standard SFML classes for loading and displaying sprites. I implemented functions from these two classes in one single class which loads and animates sprites.

How to make a Game ? Steps on how to start simple

Interactive games are getting bigger and bigger. They started from a simple Pong game on a TV. Now they are pure art, with graphics, sounds, interactions and other stuff to make you feel the experience under your skin.

The simplest answer to a game is fun. How fun can fun be ? That depends on your style. Modern games are hitting the biggest market. And if you are a game developer, then you are rich. But making a game its not that simple than playing it. Even though the hard work can be payed off, you are going to get a big pain in the ass. Yes, sorry for the disclaimer but remember just one thing. Games are fun, and creating them is more than fun. Below we offer you some steps on how to enter the amazing world of game making.

Wednesday, 14 August 2013

Introducing UMLet: excellent free UML tool

Just as the saying stands: "Reduce everything to its essence so that form harmonizes with function", graphical diagramming notations have considerably helped for better communication and understanding in Software Development.

A diagram can help us better express our ideas about Software Design without putting textual explanations. It's already confirmed that human brain better processes images than texts. That's why graphical representation through diagrams is quite effective to communicate and express our ideas either for a Software System or a Business Process.

Tuesday, 25 June 2013

Age of Empires on Android and iOS

Age of Empires Fans. Brace yourself! One of the most famous and played games of all times Age of Empires will be developed for mobile devices. Apparently, Microsoft has made a licensing agreement with KLab Inc. to develop a mobile version of Age of Empires franchise.

This news for a mobile version of Age of Empires come after 2 months when they published a remake for Age of Empires II HD. It's no wonder that Age of Empires has such a strong fan base worldwide and is widely considered as one of the best games ever. As i already said Age of Empires is one of the most successful game franchises in the market. This historical strategy game has won the heart of many fans throughout the world. Microsoft revived their Age of Empires II on April with improved graphics and available for download through Steam as Age of Empires II HD.

Monday, 24 June 2013

Android Jelly Bean 4.2.2 coming for Samsung Galaxy S III

Android Jelly Bean 4.2.2
Android Jelly Bean 4.2.2
It's been revealed. Just as promised,  Android Jelly Bean 4.2.2 comes for Samsung Galaxy S III with many of the features already present at Samsung Galaxy S IV.  Samsung seems to care about updating their older mobile devices with newer System Updates.  The update for Jelly Bean 4.2.2 will likely come in either July or August. I guess many are excited and are impatient for the release of the update. 

Thanks to SamMobile  we already can download the pre release for Jelly Bean 4.2.2.  Well, as we already know Samsung promised that it will bring the Android Jelly Bean 4.2.2 to their Samsung Galaxy S III phones immediately a while after they released their newly Samsung Galaxy S IV smartphone. 

Saturday, 8 June 2013

Tips: How to Make Money Online

Online Money
Online Money
The Internet is definitely one of the most important Innovations that the humans have made. It has tremendously changed almost every human activity and perspective of the world starting from easier communication, economic bust, widespread knowledge as well as a global world system which connects people from various continents each other.

Internet has introduced new improved business models which made information overflow in and out of organizations easier, faster and more accurate. Perhaps, it has played a role in ruining several jobs but it also opened a ways for another incoming jobs. With the introduction of Web 2.0 this has already boosted the importance of Internet opening the way for even finishing job tasks online. 

Tuesday, 4 June 2013

Unreal Engine 4 : New features and scripting systems

Legions of developers rely upon Unreal Engine 3’s Unreal Kismet, which is used to quickly build gameplay prototypes and level events. With Unreal Engine 4, Epic introduces Blueprints, a revolutionary new visual scripting system that replaces Kismet and provides a massive leap in functionality and productivity for projects large or small. Blueprint visual scripting empowers artists and designers like never before by providing access to low-level engine functions and the ability to rapidly prototype without having to write a single line of code.

Tuesday, 28 May 2013

OUYA: New Android based Game Console

OUYA Console
OUYA Console
Another innovative project funded via Kickstarter.  It is Kickstarter's most backed project exceeding $8 million, it was named OUYA and it is a video game console with it's own Android Operating System aiming to bring games into big screens. The console is open for anyone to easily build games and bring them on TV.

It will probably be an attractive console for Indie Developers to bring their creative and innovative gameplay. OUYA Game Console would be available for just $99 and it will attempt to bring on TV screen cheaper games unlike the major Consoles and their expensive games.

Friday, 24 May 2013

Boolean Algebra - Digital Logic

Digital Logic
Boolean Algebra plays a crucial role on every aspect of Computer Science. In programming we know it as true or false statements whereas in digital logic we have 1 and 0. We can use these statements to determine different types of behavior whether in programming or in electronic circuit design. We will see how we can transform entire mathematical formula and design a circuit with the help of boolean algebra.

In these modern days of technology, smart electronic chips have capacities to choose different types of behavior and even playing intelligent based on events that behave upon them. To do so chips use boolean algebra to compare or do branching depending on the logic that has been designed for them.

Wednesday, 22 May 2013

Case Sample: Cinema Application SQL Queries

Cinema Use Case Diagram
Cinema App Features
In one of my previous posts i explained the creation of Database Structure of our Cinema Application. You can proceed reading it here: Case Sample: Cinema Application ER Diagrams In this post, i started from scratch by firstly putting the requirement for Cinema Application and then designing the ER Diagrams.

With the ER Diagrams we catch many logical connections and constraints of our Application. Then, i proceeded with the conversion of ER Diagrams into Relational Schema and the actual SQL Implementation. For further read proceed here: Case Sample: Cinema Application, ER to Relational Model mapping and SQL implementation Now, i am going to implement couple of SQL queries and deduce some interesting statistics from our actual Database.

Monday, 20 May 2013

Binary Numbers - Addition

Binary Numbers
Binary Numbers
Arithmetic operations with binary numbers can be useful especially if you want to learn machine language, or you are programming an electronic chip or maybe a central processing unit CPU.

We can do arithmetic operations with binary numbers just like we do with decimals. Simple enough, arithmetic operations can be very straightforward we just need to follow some rules and concentration. Since we work only with two digits 0 and 1 some operations can be challenging, however a bit of concentration will allow your logic to clear its path. So lets see how electronic machines actually do math on their way.

Sunday, 19 May 2013

Which programming language should i learn ? - Answer yourself !

Programming Languages
Programming Languages
Choosing a programming language can be difficult. It all depends on your needs. But the overall logic is always the same. When programming you are solving problems. When choosing a programming language you are not choosing simplicity, rather you are changing the syntax of commands you write.

So do not be trolled by the idea that there is a language that is easier and can do complex tasks. Remember a programming language is not a software. It all depends on what you are going to program. Even assembly can be easy if you use it just to multiply two numbers.


© 2013 smartnoob . All rights resevered. Designed by Templateism