<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9072060952310429390</id><updated>2011-11-27T15:22:47.489-08:00</updated><category term='string manipulation'/><category term='stringstream'/><category term='solution'/><category term='prime number'/><category term='maths'/><category term='programming'/><category term='sscanf'/><category term='program'/><category term='string'/><category term='geometry'/><category term='coordinate geometry'/><category term='palindrome'/><category term='category'/><category term='interview'/><category term='islower'/><category term='substring'/><category term='job'/><category term='boundary conditions'/><category term='ctype.h'/><category term='minesweeper'/><category term='toupper'/><category term='coding'/><category term='microsoft'/><category term='code optimization'/><category term='effecient code'/><category term='Question'/><category term='programing'/><category term='code'/><category term='c++'/><category term='answer'/><category term='c++ strings'/><category term='recursion'/><category term='google'/><category term='problem'/><title type='text'>How to write a Program?</title><subtitle type='html'>Simple programming problems, with simple solutions to guide you towards writing better programs. A lot of C++ tidbits come as a bonus.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-2737383340287820221</id><published>2008-05-11T20:26:00.000-07:00</published><updated>2008-05-11T21:13:23.581-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='minesweeper'/><title type='text'>Minesweeper</title><content type='html'>If you are designing a minesweeper game, you would need to mark each block with how many mines are adjacent to it. &lt;br /&gt;&lt;br /&gt;Write a program that places mines in a square grid. And marks each block with the number of mines adjacent to it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-2737383340287820221?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/2737383340287820221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=2737383340287820221' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2737383340287820221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2737383340287820221'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/minesweeper.html' title='Minesweeper'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-1037973620777457380</id><published>2008-05-09T23:19:00.001-07:00</published><updated>2008-12-10T04:39:17.766-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='palindrome'/><category scheme='http://www.blogger.com/atom/ns#' term='toupper'/><category scheme='http://www.blogger.com/atom/ns#' term='islower'/><category scheme='http://www.blogger.com/atom/ns#' term='ctype.h'/><category scheme='http://www.blogger.com/atom/ns#' term='c++ strings'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><title type='text'>Palindromes - Solution</title><content type='html'>There are multiple ways to solve this trivial problem. &lt;br /&gt;For a beginner, there is one catch in this problem. &lt;span style="font-weight:bold;"&gt;How to make it case insensitive?&lt;/span&gt; Basically, we can do so by changing the string to all upper or all lowercase letters and then check for palindromes. &lt;br /&gt;&lt;br /&gt;There maybe any number of ways to approach this problem. I'll list down the 2 ways that  usually people apply. &lt;br /&gt;&lt;br /&gt;1. Reverse the string and check if the strings are the same&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sD3jnbzxjdE/SCVEjh3PYiI/AAAAAAAAAEQ/qk0BEidnGEs/s1600-h/1.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_sD3jnbzxjdE/SCVEjh3PYiI/AAAAAAAAAEQ/qk0BEidnGEs/s400/1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5198636722045280802" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There are quite a few things to learn here.&lt;br /&gt;i&gt; There are library functions available to check if a character is uppercase or lowercase. There are also functions to convert a character from uppercase to lowercase and visa-versa. You can find these functions is ctype.h header file. &lt;br /&gt;ii&gt; Note that we did not compare the reverse of the string with str using the '==' operator. Can you guess why? Basically, because the '==' operator returns true only if the two strings share the same memory location. So we use the 'compare' method in the 'string' class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Compare the 1st against the last character, 2nd against the 2nd last character and so on till we reach the middle. &lt;br /&gt;This one is simple. Here is the code. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sD3jnbzxjdE/SCVJNB3PYjI/AAAAAAAAAEY/1RzqOIgWzus/s1600-h/2.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_sD3jnbzxjdE/SCVJNB3PYjI/AAAAAAAAAEY/1RzqOIgWzus/s400/2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5198641833056363058" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Click on the images for code clarity.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-1037973620777457380?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/1037973620777457380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=1037973620777457380' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1037973620777457380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1037973620777457380'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/palindromes-solution.html' title='Palindromes - Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sD3jnbzxjdE/SCVEjh3PYiI/AAAAAAAAAEQ/qk0BEidnGEs/s72-c/1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-6099907690096589651</id><published>2008-05-09T20:55:00.000-07:00</published><updated>2008-05-09T22:56:21.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><title type='text'>Problem 9 - Palindromes</title><content type='html'>Write a program to find if a string is a palindrome.&lt;br /&gt;Make it case insensitive.&lt;br /&gt;&lt;br /&gt;Eg. "MADAM" - returns true&lt;br /&gt;    "ROB"   - returns false&lt;br /&gt;    "Madam" - returns true&lt;br /&gt;    "mADaM" - returns true&lt;br /&gt;    "WhaWha"- returns false&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-6099907690096589651?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/6099907690096589651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=6099907690096589651' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/6099907690096589651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/6099907690096589651'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/problem-9-palindromes.html' title='Problem 9 - Palindromes'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-2022408741783555481</id><published>2008-05-09T07:36:00.000-07:00</published><updated>2008-12-10T04:39:18.111-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='c++ strings'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><title type='text'>Day 8 - Solution</title><content type='html'>The first way is to go by a Brute Force string matching technique.&lt;br /&gt;I guess its useless to give the algorithm if you are giving the source code anyways. &lt;br /&gt;&lt;br /&gt;So here is the program.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sD3jnbzxjdE/SCRk5B3PYgI/AAAAAAAAAD8/6GTJxyCrPXo/s1600-h/bruteForceStrMatch.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sD3jnbzxjdE/SCRk5B3PYgI/AAAAAAAAAD8/6GTJxyCrPXo/s400/bruteForceStrMatch.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5198390800807846402" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now lets try to do the same using the built in features of the 'string' class. Remember, our strings are not (char *) any more, they are objects of the 'string' class. Check out how our whole function that we wrote above, is replaced with a single statement.&lt;br /&gt;&lt;br /&gt;Prog:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sD3jnbzxjdE/SCRmlx3PYhI/AAAAAAAAAEE/3s6D-qW-_gQ/s1600-h/string2.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_sD3jnbzxjdE/SCRmlx3PYhI/AAAAAAAAAEE/3s6D-qW-_gQ/s400/string2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5198392669118620178" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Note: Click on the image for clarity in reading.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-2022408741783555481?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/2022408741783555481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=2022408741783555481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2022408741783555481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2022408741783555481'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-8-solution.html' title='Day 8 - Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sD3jnbzxjdE/SCRk5B3PYgI/AAAAAAAAAD8/6GTJxyCrPXo/s72-c/bruteForceStrMatch.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-1152624374678540955</id><published>2008-05-06T22:58:00.000-07:00</published><updated>2008-05-06T23:02:59.340-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='substring'/><title type='text'>Day 8 - Substring</title><content type='html'>You are given two strings - haystack and needle.&lt;br /&gt;You have to find the position of the first occurrence of needle in haystack. &lt;br /&gt;Write a function that takes haystack and needle as input and returns the position of the first occurrence of needle or -1 if needle is not found in haystack.&lt;br /&gt;&lt;br /&gt;Eg. &lt;br /&gt;&lt;br /&gt;haystack = "Once upon a time, there lived a little boy named Jingle!"&lt;br /&gt;needle = "up"&lt;br /&gt;Return Value = 5&lt;br /&gt;&lt;br /&gt;If needle = "fox"&lt;br /&gt;Return Value = -1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-1152624374678540955?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/1152624374678540955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=1152624374678540955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1152624374678540955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1152624374678540955'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-8-substring.html' title='Day 8 - Substring'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-5162285297806376954</id><published>2008-05-06T11:52:00.001-07:00</published><updated>2008-12-10T04:39:18.405-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='c++ strings'/><category scheme='http://www.blogger.com/atom/ns#' term='stringstream'/><title type='text'>Day 7 - Solution</title><content type='html'>In a hurry today. &lt;br /&gt;Please see the code!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sD3jnbzxjdE/SCCvOSVqalI/AAAAAAAAADw/5X0q6Mr2_nU/s1600-h/function_part.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sD3jnbzxjdE/SCCvOSVqalI/AAAAAAAAADw/5X0q6Mr2_nU/s400/function_part.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5197346629961280082" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click on the image for clarity.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-5162285297806376954?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/5162285297806376954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=5162285297806376954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5162285297806376954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5162285297806376954'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-7-solution.html' title='Day 7 - Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sD3jnbzxjdE/SCCvOSVqalI/AAAAAAAAADw/5X0q6Mr2_nU/s72-c/function_part.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-8737986289663270265</id><published>2008-05-05T22:12:00.000-07:00</published><updated>2008-05-06T12:08:26.795-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='string manipulation'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Day 7 - Who Won?</title><content type='html'>You are given an array of strings containing a 3 letter country name followed by a hyphen (-) and A 3 digit number. These strings represent the number of points earned by the students of the respective country in a programming competition.&lt;br /&gt;NOTE: There are only 3 countries participating, India, China and USA. The 3 letter code for the countries are IND, CHI and USA respectively.&lt;br /&gt;&lt;br /&gt;Write a function that calculates the total number of points scored by the students of IND, CHI and USA and returns a string in the same format with the country code followed by a hyphen followed by the total points scored by the country which has the highest points.&lt;br /&gt;&lt;br /&gt;eg&lt;br /&gt;INPUT -&gt; ["IND-32","CHI-33","USA-29","USA-30","IND-12","CHI-34"]&lt;br /&gt;OUTPUT -&gt; "CHI-67"&lt;br /&gt;&lt;br /&gt;NOTE: It is guaranteed that the sum of the scores won't be equal.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-8737986289663270265?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/8737986289663270265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=8737986289663270265' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8737986289663270265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8737986289663270265'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-7-who-won.html' title='Day 7 - Who Won?'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-1658077473283884099</id><published>2008-05-05T06:20:00.000-07:00</published><updated>2008-12-10T04:39:19.170-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='sscanf'/><category scheme='http://www.blogger.com/atom/ns#' term='c++ strings'/><category scheme='http://www.blogger.com/atom/ns#' term='stringstream'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><category scheme='http://www.blogger.com/atom/ns#' term='string'/><title type='text'>Day 6 - Solution</title><content type='html'>The problem here is to break the string into corresponding numbers. &lt;br /&gt;&lt;br /&gt;There are 2 general ways of going about it. &lt;br /&gt;&lt;br /&gt;1. Using &lt;span style="font-weight:bold;"&gt;String Streams&lt;/span&gt;.&lt;br /&gt;String Streams are a mechanism of converting a string to a stream. So you can do things like write to the stream and read from the stream, very similar to how you use &lt;span style="font-weight:bold;"&gt;cout&lt;/span&gt; and the &lt;span style="font-weight:bold;"&gt;&lt;&lt; operator&lt;/span&gt; to write to Standard Output Stream and &lt;span style="font-weight:bold;"&gt;cin&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;&gt;&gt; operator&lt;/span&gt; to read from the Standard Input Stream.&lt;br /&gt;&lt;br /&gt;So we initialize a String Stream with our string - namely DOB. &lt;br /&gt;We then read the day, the '/' character, the month, the '/' character and the year from it. &lt;br /&gt;&lt;br /&gt;Check the Program. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sD3jnbzxjdE/SB8LASVqaiI/AAAAAAAAADQ/YULKYxUA3m0/s1600-h/progStringStream.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_sD3jnbzxjdE/SB8LASVqaiI/AAAAAAAAADQ/YULKYxUA3m0/s400/progStringStream.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5196884594559445538" /&gt;&lt;/a&gt;&lt;br /&gt;Click on the image for a clearer view.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. The 2nd way is using &lt;span style="font-weight:bold;"&gt;sscanf()&lt;/span&gt;&lt;br /&gt;The syntax of sscanf is very similar to scanf, only that you need to specify the string that it needs to scan as the first argument. Note that sscanf() is a C compatible function so our string object (dob) won't work with it. We will have to convert it to a C compatible string. That is attained by using the &lt;span style="font-weight:bold;"&gt;c_str()&lt;/span&gt; functionality built in the string class. &lt;br /&gt;eg  string obj -&gt; "12/3/00" &lt;br /&gt;obj.c_str() =&gt; char * =&gt; "12/3/00\0"&lt;br /&gt;&lt;br /&gt;You'll understand better by having a look at the program.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SB8MSCVqajI/AAAAAAAAADY/PHgIUrlGoEc/s1600-h/sscanfProg.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SB8MSCVqajI/AAAAAAAAADY/PHgIUrlGoEc/s400/sscanfProg.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5196885999013751346" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Click on the image for a clearer view.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The result of both the program is the same:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SB8MaCVqakI/AAAAAAAAADg/N93hs2E443A/s1600-h/result1.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SB8MaCVqakI/AAAAAAAAADg/N93hs2E443A/s400/result1.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5196886136452704834" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you know of any other ways, please bring it to my notice :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-1658077473283884099?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/1658077473283884099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=1658077473283884099' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1658077473283884099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1658077473283884099'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-6-solution.html' title='Day 6 - Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sD3jnbzxjdE/SB8LASVqaiI/AAAAAAAAADQ/YULKYxUA3m0/s72-c/progStringStream.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-2867282585839474497</id><published>2008-05-05T04:12:00.000-07:00</published><updated>2008-05-05T05:59:55.522-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Day 6 - Question : Breaking Strings</title><content type='html'>You are given a string containing a string Date of Birth in DD/MM/YYYY format. Eg "15/08/1947". Write a function that takes the string as an input and returns a vector&lt;int&gt; containing 3 elements: &lt;br /&gt;v[0] = Day as an integer&lt;br /&gt;v[1] = Month as an integer&lt;br /&gt;v[2] = Year as an integer&lt;br /&gt;&lt;br /&gt;eg: &lt;br /&gt;INPUT : "15/08/1947"&lt;br /&gt;Output: [15, 8, 1947]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-2867282585839474497?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/2867282585839474497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=2867282585839474497' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2867282585839474497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2867282585839474497'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-6-question-breaking-strings.html' title='Day 6 - Question : Breaking Strings'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-7723341024199225147</id><published>2008-05-03T10:25:00.000-07:00</published><updated>2008-12-10T04:39:19.254-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Day 5 Solution</title><content type='html'>There is nothing special about this problem. No holistic views, no boundary conditions.  You guys know "Sorting" right! This problem is to make you use it. &lt;br /&gt;&lt;br /&gt;The Algorithm&lt;br /&gt;1. Sort the array from 0 to n-1&lt;br /&gt;2. Return the n-2th element&lt;br /&gt;&lt;br /&gt;--- &lt;br /&gt;&lt;br /&gt;So you can do your regular sorting thing and get the result.&lt;br /&gt;&lt;br /&gt;I would like to use this opportunity to introduce you to some more of STL.&lt;br /&gt;&lt;br /&gt;Check the program&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sD3jnbzxjdE/SByk8iVqahI/AAAAAAAAADI/bmxA5OTEoBs/s1600-h/1.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_sD3jnbzxjdE/SByk8iVqahI/AAAAAAAAADI/bmxA5OTEoBs/s400/1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5196209429995481618" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There is a legacy trick of finding the size of an array in that problem. &lt;br /&gt;Noticed how we did - &lt;br /&gt;&lt;blockquote&gt;          sizeof(heights)/sizeof(int)&lt;/blockquote&gt; &lt;br /&gt;to get the number of elements in the array!&lt;br /&gt;&lt;br /&gt;Then, while converting that array into a vector, we need to give the range of the array. By range I mean, a pointer (or an iterator) from the beginning of the array to the end of the array. Now 'heights' will give us the pointer to the beginning of the array and 'heights + n' to the end. &lt;br /&gt;&lt;br /&gt;But will 'heights + n' always give us the pointer to the end of the array? &lt;br /&gt;It will in our case, but it wont for other arrays of other types. &lt;br /&gt;Can you tell why?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-7723341024199225147?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/7723341024199225147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=7723341024199225147' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/7723341024199225147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/7723341024199225147'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-5-solution.html' title='Day 5 Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sD3jnbzxjdE/SByk8iVqahI/AAAAAAAAADI/bmxA5OTEoBs/s72-c/1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-8541307738071966257</id><published>2008-05-03T10:17:00.000-07:00</published><updated>2008-05-03T10:22:46.171-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><title type='text'>Day 5 - The second tallest student</title><content type='html'>Problem - You are given an integer array of heights of students in a class. Write a function that returns the height of the 2nd tallest child in the class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-8541307738071966257?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/8541307738071966257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=8541307738071966257' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8541307738071966257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8541307738071966257'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-5-second-tallest-student.html' title='Day 5 - The second tallest student'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-7194892980345180544</id><published>2008-05-02T04:14:00.000-07:00</published><updated>2008-12-10T04:39:19.769-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='boundary conditions'/><category scheme='http://www.blogger.com/atom/ns#' term='coordinate geometry'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Day 4 Solution</title><content type='html'>You can view the problem statement &lt;a href="http://iwannacode.blogspot.com/2008/05/day-4-problem-whats-distance.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now you can imagine the gird to be a something like this &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBr6XSVqadI/AAAAAAAAACo/s7sMGzJv8L4/s1600-h/ssm_grids1_1.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBr6XSVqadI/AAAAAAAAACo/s7sMGzJv8L4/s400/ssm_grids1_1.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5195740398091921874" /&gt;&lt;/a&gt;&lt;br /&gt;Point A could be your home and Point B your school/college.&lt;br /&gt;&lt;br /&gt;So you would be thinking that (Ax - Bx) and (Ay - By) would give you your solution. But the solution could be negative as well. So you take the absolute value of (Ax - Bx) and (Ay - By) and add the two to get your answer. &lt;br /&gt;&lt;br /&gt;Check the program.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBsSBCVqagI/AAAAAAAAADA/-yGssklukoo/s1600-h/1.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBsSBCVqagI/AAAAAAAAADA/-yGssklukoo/s400/1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5195766404118899202" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now the catch is...&lt;br /&gt;While writing/imagining the solution, did you imagine only the positive co-ordinate axis or all the 4 axes? As in, did you imagine only positive co-ordinates for X and Y or did you imagine the negative ones as well?&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBr-IyVqafI/AAAAAAAAAC4/_XZF9ajHD2M/s1600-h/xy-graph2.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBr-IyVqafI/AAAAAAAAAC4/_XZF9ajHD2M/s400/xy-graph2.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5195744547030329842" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you imagined the Negative Axes as well then congrats! You are someone who already looks at boundary conditions. And if you did not, then congrats! You can start looking at boundary conditions for every problem you solve from now on!&lt;br /&gt;&lt;br /&gt;In our case, the solution works well no mater which quadrant we are in. But real life problems, I'm afraid, are not so forgiving.  &lt;br /&gt;&lt;br /&gt;So did you find this post insightful? Keep bringing on your comments. I am looking forward to some readers posting a snapshot of their solutions too!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-7194892980345180544?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/7194892980345180544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=7194892980345180544' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/7194892980345180544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/7194892980345180544'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-4-solution.html' title='Day 4 Solution'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sD3jnbzxjdE/SBr6XSVqadI/AAAAAAAAACo/s7sMGzJv8L4/s72-c/ssm_grids1_1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-8623982459704307214</id><published>2008-05-02T03:26:00.000-07:00</published><updated>2008-05-02T04:25:47.872-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='maths'/><category scheme='http://www.blogger.com/atom/ns#' term='Question'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='geometry'/><title type='text'>Day 4 problem - Whats the distance</title><content type='html'>Here is todays problem.&lt;br /&gt;&lt;br /&gt;You have a square grid extending infinitely in all directions. Your home is at point (hx,hy). You have to reach your college located at point (cx, cy). You can only travel parallel to the direction of the X or the Y axis and each step is 1 unit long. Write a program to find the number of steps between your home and your college. &lt;br /&gt;&lt;br /&gt;Write it now. Test it. And come back later to check the solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-8623982459704307214?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/8623982459704307214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=8623982459704307214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8623982459704307214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/8623982459704307214'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/day-4-problem-whats-distance.html' title='Day 4 problem - Whats the distance'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-4970006464773525392</id><published>2008-05-01T05:44:00.000-07:00</published><updated>2008-05-01T06:28:33.660-07:00</updated><title type='text'>Solution to Day 3 problem.</title><content type='html'>View the problem statement &lt;a href="http://iwannacode.blogspot.com/2008/04/day-3-programming-problem-shortest.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This problem is very simple, yet I have included it because I want the readers to start using some STL in their C++ programs. &lt;br /&gt;&lt;br /&gt;What is STL?&lt;br /&gt;It stands for Standard Template Library. This library has a lot of classes and functions that can replace a lot of data structures and algorithms that we use on a regular basis.&lt;br /&gt;&lt;br /&gt;In order to solve our problem we can use the following algorithm&lt;br /&gt;1. Set height[0] as RES&lt;br /&gt;2. Loop through height, from begin to end&lt;br /&gt;&lt;blockquote&gt;      if current_element in height is &lt; RES&lt;br /&gt;         set RES to current_element&lt;/blockquote&gt;&lt;br /&gt;3. Return RES&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, how do we use STL to do this?&lt;br /&gt;We use STLs Algorithms.&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;#include&amp;lt;algorithm&amp;gt;&lt;br /&gt;#include&amp;lt;vector&amp;gt;&lt;br /&gt;&lt;br /&gt;int minHeight(vector&amp;lt;int&amp;gt; height)&lt;br /&gt;{&lt;br /&gt;    return *min_element(height.begin(),height.end()) ;&lt;br /&gt;}&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;&lt;br /&gt;OK OK, that seems to be too much too soon. &lt;br /&gt;So lets break it down.&lt;br /&gt;&lt;br /&gt;Q1. Whats that vector thingy? We were supposed to have an array as an input!&lt;br /&gt;Ans. Vector is an STL class. Vectors are a replacement for Arrays. The &amp;lt;int&amp;gt; tells that its an array of int(s). &lt;br /&gt;&lt;br /&gt;Q2. What is min_element?&lt;br /&gt;Ans. min_element is a pre-defined* function in algorithm.h that returns a pointer to the minimum element in a specified range.&lt;br /&gt;&lt;br /&gt;Q3. So height.begin(), height.end() are ranges right?&lt;br /&gt;Ans. Exactly. height.begin() returns a pointer to the beginning of the array and height.end() returns a pointer to 1 past the end of the array. Between begin() and end() we have covered the whole array.&lt;br /&gt;&lt;br /&gt;We will be talking a lot about using STL subsequently.&lt;br /&gt;You can try the program out and let me know if there are any doubts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;* functions are declared not defined in header files. They are defined in the respective libraries.&lt;br /&gt;&lt;br /&gt;Note: In reality, min_element() returns something called an iterator which is similar to a pointer and you don't have to bother much about it right now. STL is a very simple to use library with easy syntax, but the way it is taught in books is a bit daunting. So don't bother much about the syntax if you are reading it for the first time. Just see a few examples and learn from them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-4970006464773525392?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/4970006464773525392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=4970006464773525392' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/4970006464773525392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/4970006464773525392'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/05/solution-to-day-3-problem.html' title='Solution to Day 3 problem.'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-5376721179397181102</id><published>2008-04-30T23:10:00.000-07:00</published><updated>2008-05-01T05:49:42.089-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Day 3 - Programming problem: Shortest height</title><content type='html'>Question: You are given an array height[] of positive integers containing the heights of the children in a class. Write a function that takes height[] as an input and gives the shortest height as the output.&lt;br /&gt;&lt;br /&gt;For example - &lt;br /&gt;Input - [23,29,20,22,23,22,19,25,21,26,23,24,18,30]&lt;br /&gt;Output - 18&lt;br /&gt;&lt;br /&gt;Request: Pls take the quiz the right side bar to give feedback on the easiness/difficulty level of the questions. Thanks&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-5376721179397181102?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/5376721179397181102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=5376721179397181102' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5376721179397181102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5376721179397181102'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/day-3-programming-problem-shortest.html' title='Day 3 - Programming problem: Shortest height'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-9036854643571291472</id><published>2008-04-29T21:30:00.000-07:00</published><updated>2008-12-10T04:39:20.189-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='boundary conditions'/><category scheme='http://www.blogger.com/atom/ns#' term='prime number'/><category scheme='http://www.blogger.com/atom/ns#' term='code optimization'/><category scheme='http://www.blogger.com/atom/ns#' term='interview'/><category scheme='http://www.blogger.com/atom/ns#' term='job'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft'/><category scheme='http://www.blogger.com/atom/ns#' term='effecient code'/><title type='text'>Solution to Problem 2</title><content type='html'>You can view the problem statement &lt;a href="http://iwannacode.blogspot.com/2008/04/problem-set-2.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Why did I ask this question now? &lt;br /&gt;Because there are 3 good things in this problem :-&lt;br /&gt;1. You need to understand the problem.&lt;br /&gt;2. There is a lot you can do to optimize the solution&lt;br /&gt;3. If you don't optimize the solution, you may end up screwing your reputation in your job interview.&lt;br /&gt;&lt;br /&gt;Remember, anyone can code. But the way anyone will differentiate between you and an average coder is on the basis of &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; How well you handle the boundary conditions. (Does your code fail for any input)&lt;/li&gt;&lt;br /&gt;&lt;li&gt; How efficient your code is. &lt;/li&gt;&lt;br /&gt;&lt;li&gt; And how well can you optimize your code. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Many people coming to this blog are students who would be writing programs in their job interviews soon. I can tell from personal experience that the sexiest of companies only ask for programmers who code keeping the above points in their mind. &lt;br /&gt;&lt;br /&gt;Ok now coming back to the problem. &lt;br /&gt;&lt;br /&gt;We can check for primality by iterating from 2 to (n-1) and if it is divisible by any number in between, we can be sure that it is not a prime number. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBgGoyVqacI/AAAAAAAAACg/1CHIESyML1U/s1600-h/2.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBgGoyVqacI/AAAAAAAAACg/1CHIESyML1U/s400/2.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194909467949033922" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;However, there is a lot of unnecessary iteration over here. &lt;br /&gt;You might be thinking that, since we are starting from 2, we can stop iterating when i reaches (n/2). &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sD3jnbzxjdE/SBf9MSVqaaI/AAAAAAAAACQ/QzNLgS0Ze9M/s1600-h/3.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_sD3jnbzxjdE/SBf9MSVqaaI/AAAAAAAAACQ/QzNLgS0Ze9M/s400/3.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194899082718112162" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Well you are right. But the number of iterations can be optimized further.&lt;br /&gt;&lt;br /&gt;Consider, a number 21. Lets list down its divisors&lt;br /&gt;1 x 21 = 21&lt;br /&gt;3 x 7  = 21&lt;br /&gt;7 x 3  = 21&lt;br /&gt;21 x 1 = 21&lt;br /&gt;After removing the first and the last case. We are left with only 3 x 7 and 7 x 3. Notice the repetition. Once we have 3 we dont need to go till 7 do we? &lt;br /&gt;Now you would argue that, our program will automatically come out of the loop at 3 so there is no question of reaching all the way till 7. Well you are right again. But the problem doesn't come when the input is composite (A number that is not prime). The problem comes when the number is prime. Take 23 for example. &lt;br /&gt;Try dividing it with :-&lt;br /&gt;2 - No&lt;br /&gt;3 - No&lt;br /&gt;4 - No&lt;br /&gt;5 - No&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;11 - No&lt;br /&gt;And then we come out of the loop.&lt;br /&gt;&lt;br /&gt;But do we really need to go all the way till 11? &lt;br /&gt;No we don't. &lt;br /&gt;Applying some common sense, you can sense that after the square root of the number, the order of multiplication starts changing. &lt;br /&gt;Let me illustrate that with an example. &lt;br /&gt;&lt;br /&gt;Consider n = 24&lt;br /&gt;2 x 12 = 24&lt;br /&gt;3 x 8  = 24&lt;br /&gt;4 x 6  = 24&lt;br /&gt;6 x 4  = 24&lt;br /&gt;8 x 3  = 24&lt;br /&gt;12 x 2 = 24&lt;br /&gt;&lt;br /&gt;The divisors start repeating after i becomes greater than 5. Its basically because, i becomes &gt; 4.89 or Square Root(24). So we only need to iterate till the square root of a number. &lt;br /&gt;&lt;br /&gt;Here is the code for the problem.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBgCoSVqabI/AAAAAAAAACY/c-8-CJhMSKM/s1600-h/1.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBgCoSVqabI/AAAAAAAAACY/c-8-CJhMSKM/s400/1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194905061312588210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now coming back to the 3 points that I had mentioned earlier on why this problem is good. &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1. You need to understand the problem.&lt;/span&gt; Did you know that, prime numbers can't be negative? I didn't know it when I was asked to write this program the first time.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2. There is a lot you can do to optimize the solution&lt;/span&gt; You already have an idea of the optimization now.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;3. If you don't optimize the solution, you may end up screwing your reputation in your job interview.&lt;/span&gt; If you apply for a job in a company like Google, Microsoft, Trilogy or an uber-cool startup. They are really gonna see how well you are able to optimize your solutions.&lt;br /&gt;&lt;br /&gt;Can you find out a way of making the function return still faster for a random input?&lt;br /&gt;Thats your assignment.&lt;br /&gt;&lt;br /&gt;Thats all for the day. &lt;br /&gt;Trust you found the post interesting. &lt;br /&gt;&lt;br /&gt;Full_Metal&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-9036854643571291472?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/9036854643571291472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=9036854643571291472' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/9036854643571291472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/9036854643571291472'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/solution-to-problem-2.html' title='Solution to Problem 2'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sD3jnbzxjdE/SBgGoyVqacI/AAAAAAAAACg/1CHIESyML1U/s72-c/2.bmp' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-3554704998789134608</id><published>2008-04-29T12:24:00.000-07:00</published><updated>2008-04-29T21:35:14.567-07:00</updated><title type='text'>Problem 2</title><content type='html'>Todays Problem.&lt;br /&gt;&lt;br /&gt;Write a program to check if a number is a Prime Number. &lt;br /&gt;Note: A prime number is a natural number &gt; 1 which is divisible only by 1 and the number itself. This is what Wikipedia say about &lt;a href="http://en.wikipedia.org/wiki/Prime_number"&gt;Prime Numbers&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-3554704998789134608?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/3554704998789134608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=3554704998789134608' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3554704998789134608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3554704998789134608'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/problem-set-2.html' title='Problem 2'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-3461647017987538236</id><published>2008-04-29T02:36:00.000-07:00</published><updated>2008-12-10T04:39:20.348-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='recursion'/><category scheme='http://www.blogger.com/atom/ns#' term='answer'/><category scheme='http://www.blogger.com/atom/ns#' term='solution'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Solution to Group 3 Problem</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Group 3.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;View the question &lt;a href="http://iwannacode.blogspot.com/2008/04/todays-question-group-3.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here we want to practice a bit of recursion.&lt;br /&gt;Whenever you go about writing recursive code, you have to keep two things in mind. &lt;br /&gt;1. There must be a terminating condition.&lt;br /&gt;2. As the number of recursions increase, the problem state should approach the terminating condition. &lt;br /&gt;&lt;br /&gt;Lets see that with respect to this program.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBbt9SVqaYI/AAAAAAAAACA/XVJSB6H0Vlw/s1600-h/4.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_sD3jnbzxjdE/SBbt9SVqaYI/AAAAAAAAACA/XVJSB6H0Vlw/s400/4.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194600857368947074" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now lets come back to the 2 conditions that we discussed above.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;1. There must be a terminating condition.&lt;/span&gt; As you see, the (if n &lt; 10) is the terminating condition. It is a terminating condition because a number is returned if that condition is satisfied. (Unlike the default case which calls the function again)&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2. As the number of recursions increase, the problem state should approach the terminating condition.&lt;/span&gt; This is also satisfied because, we keep dividing the number by 10 in the default condition. So the number will keep becoming smaller and smaller and finally become &lt;10, and the terminating condition will be reached. &lt;br /&gt;&lt;br /&gt;OK, so did you find a problem with the program above?&lt;br /&gt;Yes? -&gt; Great!&lt;br /&gt;No? -&gt; If you check the &lt;a href="http://iwannacode.blogspot.com/2008/04/solution-to-group-2-problem.html"&gt;previous post&lt;/a&gt;, I have mentioned that whenever we write a program, we should check for boundary conditions. This program won't work for negative numbers. &lt;br /&gt;&lt;br /&gt;How to make it work for negative numbers?&lt;br /&gt;This is your assignment.&lt;br /&gt;&lt;br /&gt;Request: Please take the quiz or leave your comment to help me make this site more useful. Thanks&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-3461647017987538236?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/3461647017987538236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=3461647017987538236' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3461647017987538236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3461647017987538236'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/solution-to-group-3-problem.html' title='Solution to Group 3 Problem'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sD3jnbzxjdE/SBbt9SVqaYI/AAAAAAAAACA/XVJSB6H0Vlw/s72-c/4.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-2920008758617998936</id><published>2008-04-29T02:24:00.000-07:00</published><updated>2008-12-10T04:39:20.492-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Solution to Group 2 Problem</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Group 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;View the problem &lt;a href="http://iwannacode.blogspot.com/2008/04/todays-question-group-2.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here we have to add the sum of digits of a number. We can go about doing it by taking taking 1 digit at a time and adding it to the result. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBbrQyVqaXI/AAAAAAAAAB4/Dpw5Cq_9j_o/s1600-h/3.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_sD3jnbzxjdE/SBbrQyVqaXI/AAAAAAAAAB4/Dpw5Cq_9j_o/s400/3.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194597893841512818" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Note: that whenever you write programs like these, always test for boundary conditions. Eg. Will the program work when the input is 0? What if the number is a negative number? etc.  &lt;br /&gt;&lt;br /&gt;Please click on the image for clarity.&lt;br /&gt;&lt;br /&gt;Request: Please take the quiz or leave your comment to help me make this site more useful. Thanks&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-2920008758617998936?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/2920008758617998936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=2920008758617998936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2920008758617998936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2920008758617998936'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/solution-to-group-2-problem.html' title='Solution to Group 2 Problem'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sD3jnbzxjdE/SBbrQyVqaXI/AAAAAAAAAB4/Dpw5Cq_9j_o/s72-c/3.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-2423830006972202335</id><published>2008-04-28T18:48:00.000-07:00</published><updated>2008-12-10T04:39:20.845-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='program'/><category scheme='http://www.blogger.com/atom/ns#' term='answer'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Solution to Group 1 problem</title><content type='html'>I'll be writing in C++ to start with, will graduate to Java or Ruby if need be.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Group 1.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;View the problem statement &lt;a href="http://iwannacode.blogspot.com/2008/04/todays-question-for-newbies.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sD3jnbzxjdE/SBbkkCVqaVI/AAAAAAAAABo/-bc4mhkNcqw/s1600-h/1.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_sD3jnbzxjdE/SBbkkCVqaVI/AAAAAAAAABo/-bc4mhkNcqw/s400/1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194590527972600146" /&gt;&lt;/a&gt;&lt;br /&gt;Click the image to view enlarged version.&lt;br /&gt;&lt;br /&gt;Its a good practice to use functions to do the calculation part and use the main() only for calling relevant functions and I/O.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sD3jnbzxjdE/SBboniVqaWI/AAAAAAAAABw/q_fQ6ex1YFk/s1600-h/2.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_sD3jnbzxjdE/SBboniVqaWI/AAAAAAAAABw/q_fQ6ex1YFk/s400/2.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5194594986148653410" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just click on the images for clarity.&lt;br /&gt;&lt;br /&gt;Request: Please take the quiz or leave your comment to help me make this site more useful. Thanks&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-2423830006972202335?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/2423830006972202335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=2423830006972202335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2423830006972202335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/2423830006972202335'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/solution-to-problem-set-1.html' title='Solution to Group 1 problem'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sD3jnbzxjdE/SBbkkCVqaVI/AAAAAAAAABo/-bc4mhkNcqw/s72-c/1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-5269012222976280772</id><published>2008-04-28T12:09:00.000-07:00</published><updated>2008-04-28T19:26:31.287-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='category'/><title type='text'>Categories of questions</title><content type='html'>Most of the questions here will sound very trivial to a typical coder. But I am starting off with easy questions and we will graduate to tougher ones after I receive some feedback.&lt;br /&gt;&lt;br /&gt;The questions are divided into 3 categories:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Group 1&lt;/span&gt;. This question is for people who are not able to solve the Group 2 question.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Group 2&lt;/span&gt;. This question is for people who know find the Group 1 question too easy and the Group 3 question, too tough.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Group 3&lt;/span&gt;. This question is for people who found Group 1 and Group 2 questions easy to solve.&lt;br /&gt;&lt;br /&gt;Its a lame, yet common sense way to categorize!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-5269012222976280772?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/5269012222976280772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=5269012222976280772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5269012222976280772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5269012222976280772'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/categories-of-questions.html' title='Categories of questions'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-1223752002071070660</id><published>2008-04-28T12:07:00.002-07:00</published><updated>2008-04-28T19:27:26.662-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='Question'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Todays Question: Group 3</title><content type='html'>Que 1.3&gt; Write a program that finds the sum of the digits of a number, using recursion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-1223752002071070660?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/1223752002071070660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=1223752002071070660' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1223752002071070660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/1223752002071070660'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/todays-question-group-3.html' title='Todays Question: Group 3'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-333409199248343800</id><published>2008-04-28T12:05:00.000-07:00</published><updated>2008-04-28T19:28:01.951-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='Question'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Todays Question: Group 2</title><content type='html'>Que 1.2&gt; Write a program to find the sum of the digits in a number.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-333409199248343800?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/333409199248343800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=333409199248343800' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/333409199248343800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/333409199248343800'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/todays-question-group-2.html' title='Todays Question: Group 2'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-5955764388768925803</id><published>2008-04-28T12:02:00.000-07:00</published><updated>2008-04-28T19:28:36.465-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='problem'/><category scheme='http://www.blogger.com/atom/ns#' term='Question'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Todays Question: Group 1</title><content type='html'>Que 1.1&gt; Write a program to add 2 numbers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-5955764388768925803?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/5955764388768925803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=5955764388768925803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5955764388768925803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/5955764388768925803'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/todays-question-for-newbies.html' title='Todays Question: Group 1'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9072060952310429390.post-3536788232811088305</id><published>2008-04-28T10:03:00.000-07:00</published><updated>2008-04-28T11:17:18.836-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programing'/><category scheme='http://www.blogger.com/atom/ns#' term='code'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>So you wanna code huh?</title><content type='html'>The best way to be a good coder is to write code and learn from other coders better than you.&lt;br /&gt;&lt;br /&gt;I will post 1 problem every single day for people who have just started programming. I will post the solution in the night, the same day.&lt;br /&gt;&lt;br /&gt;Based on user feedback, I will make the problems tougher or easier. So, do take part in the quiz.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9072060952310429390-3536788232811088305?l=iwannacode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iwannacode.blogspot.com/feeds/3536788232811088305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9072060952310429390&amp;postID=3536788232811088305' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3536788232811088305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9072060952310429390/posts/default/3536788232811088305'/><link rel='alternate' type='text/html' href='http://iwannacode.blogspot.com/2008/04/so-you-wanna-code-huh.html' title='So you wanna code huh?'/><author><name>full_metal</name><uri>http://www.blogger.com/profile/07042259608667627170</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
