Hey folks!! Has been quite a while since I blogged last time. Well, I was kinda busy with my own dreamy world and I couldn’t grab an opportunity to actually run into doing content for you, which is quite a shame! Well, I am back and hopefully we will be having lots of fun with the new tool that I have in store for you today. We will be dealing with ‘iterations’ today. Now its kinda new for you and I would suggest that you do a good double-take at the description and visuals I have in store for you. Let’s get started.

Suggested Reading :

Visuals might just be the line between you and the app!

Do it till you are broke!

1. The statement we are going to talk about today is called the ‘for’ loop or the for iteration. It’s a very useful tool when we build apps as sometimes we do need to skip some steps which are not going to help our cause. Taking that in mind let me give you a simple syntax of how the for loop looks like-

for (<initialization>; <condition/s>; <increment/decrement>)
{
job 1;
job 2;
…..job n;
}

So as you can clearly see, this statement is really beautiful! Now I will go on with explaining each part of the statement-

for-this is the keyword we will be using every time we will want to use this iteration.
<initialization>-the for loop cannot work very well if we will not initialize the variable we are using. It gives the computer an idea of ‘where’ to start from.
<condition/s>-this consists of the ‘limitations’ or the limit to which you want the iteration to continue.
<increment/decrement>-this deals with increasing the value of the variable so that we have ‘better control’ of how the statement loop is going to work like.

2. We might even drop in a real-time example to make matters easier-

“Have you ever cleaned your room?! Now for those of you who don’t know what I am talking about, it requires you to ‘arrange’ things in order. If the condition is like your mother is going to check your room until its sparkling clean, you might have to do the scrubbing and rubbing process again and again. This can be stated in a for loop form in the following way-

for (room=unclean; room!=sparkling-clean; rub-and-arrange++)

That would be the for loop for the room-cleaning part! If you see the statement, you will realize what you have to do. From the first part, you can see that your room is at the ‘unclean’ state at the moment. So you initialize it as room=unclean. Now from the next part, we can see that the condition states, until ‘room is not clean’. That means you have to continue cleaning till its sparkling clean! Then the last part states the do it as many times until the room is clean part, or the increment the cleaning ‘rub-and-arrange’ part again and again!! Now your room is clean!”

3. All that said, it’s time for my favorite part-building the app from the statement. I have explained you how to design the interface of the app and so I will just give you a quick view of how the app is going to look like. It’s the same ‘play’ app we built last time-

4. Double click the play button and let’s do the coding part as follows-

Take a good look at the code. The value of i variable is initialized to the choice variable. Then we set the value of I to 1 and give a condition so that its value is less than 3. Then we increment it after that. Inside the for loop we have a nested ‘if-else’ statement which means that this statement is written ‘inside’ the for loop.

5. Let’s try to run the app and see what we get as an output-

6. Let’s give a choice greater than 3-

So we can see that as we had set the if-else condition to get a prized output for only choices ranging from 1 to 3, when we give an input choice of numbering greater than 3, we get the following message.

Try to improve on the app by giving even more interesting conditions. Hope you will have fun doing that. That’s all for this time, I will see you with even more cool stuffs next time around!

Do you like this post?

About

Shathyan Raja is a Blogger and Content Writer at various Blogs namely Zlobber.com and Techulator.com. Check out and contact him via Facebook Profile or Google+ Profile. He is the founder of Samsung Galaxy S 4 were you can find all updates on this upcoming smartphone.

Comments:
  1. Kate Brown Wilson

    This is an interesting topic to be honest I really don’t own an android phone, but as I have read your post it shows that there are good benefit using some application that is compatible in our phone. maybe sooner once that i have bought this gadget I would like to try this.

    • Shathyan Raja

      Hi Kate Brown,

      Thanks for the comments. Well, for this buy the Windows Phone and not the android Phone. Also hope you would give your hand to try this App development.

      • Kate Brown Wilson

        You are so much welcome Shathyan and thanks for your reply , I think that i should by my own windows phone for me to try this handy application.

  2. Gowtham

    Nice post ! Worth Sharing

    • Shathyan Raja

      Hi Gowtham,

      Thankz for the valuable comments

    • Shathyan Raja

      Hi Gautham,

      Thankz for the comments. Hope you enjoyed creating an App on own

  3. Amanda@BuySellWordPress

    I’m glad that you came back)) Hope that you got much inspiration during this break, because we all are ready for new posts and interesting information

    • Shathyan Raja

      Hi Amanda,

      Thanks for your comments. Yeah I’m back with all set of article to go for App development for Windows Phone 7

  4. Woody

    *I want it to wait
    *in

    • Shathyan Raja

      Hi Woody,

      Can you brief out what is your query. Sorry I couldn’t get you.

  5. Shathyan Raja

    Hi Woody,

    Thankz for your comments. But before you go on, I would suggest you to start the App Development from step by step. For this I would suggest you to go through my first article over this Windows Phone 7 App Development.

    http://www.comptalks.com/the-beginners-guide-to-windows-phone-7-application-development-1/

    And reading it, go from App Development step 1 to 12. Here I have written totally 14 tutorial article on Windows Phone 7 App Development.

  6. Jasmine

    Looks really interesting. I am using HTC Mozart actually, but have not gotten around to developing my own app yet. I guess developing Windows mobile app is not for everybody, really need to do a lot of reading and practicing.

Leave a Reply

(required)

(required)


Copyright © 2008-2012 Comptalks - All Rights Reserved.