Saturday, June 20, 2015

[Programming book Chapter Eight] binary search.

Let's start with a simple game. It needs two to play. I think one will find a number. Some of the questions that will get the number of the latter. However, your number? " - A question but can not be direct. The question is: What number N (a number) of greater than or equal to small? The number but would be in a certain range (eg 1 to 100, 10, 1000, from -1000 100000). Now, let's say, first, that the issue has a number from 1 through 1000. But most of the times equal to the number of N- What? ' It can be out of the question. (What is the number 1? Number 2? ... What number is the number 999 ?, 1000?). If the number must be out of the question. However, the question to be bad luck if a thousand times. But we do not have so much time. Suppose that in 1000 the number from 1 to 50. Our first question then would be: 1) The number 500 is greater than, equal to or smaller? Small. Ii) the number 250 is greater than, equal to or smaller? Small. 3) The number 125 is greater than, equal to or smaller? Small. 4) The number 62 is greater than, equal to or smaller? Small. 5) greater than the number 31, is equal to or smaller? Large. 6) What number is 46 greater than, equal to or smaller? Large. 7) The number 54 is greater than, equal to or smaller? Small. 8) What number is greater than 50, equal to or smaller? Equal. We just got the number of the eight questions! Surely you have to understand the procedure? Each time the number of questions that are in the range has been cut to half. The game was the beginning of the time limit from 1 to 1000. Then it is 1 to 500. Then from 1 to 250, 1 to 125, 1 to 62, 31, 62, 46, 62, 46 and 54. This process binary search to find the number. Let's try to write the algorithm: Binary Search (low, high, N): (at the beginning of the three of us will know the number, the lower the number (low), upper limit (high) and the number (N)) Step 1: mid = (low + high) / 2 Step 2: If the value of the mid and N- is equal to the step 5. Step 3: If the N, mid- greater than if it is at low = mid + 1. Step 1. Step 4: If the N, mid- smaller than it is, then high = mid - 1. Step 1 seconds. Step 5: the number of m (mid). Now we will see any number from an array of binary search is to find out how. But the numbers of array from small to large or small order will be. Otherwise binary search can not be used. Can anyone tell me what is the cause? First, we assume an array of integers, where the numbers are arranged in sequence from small to large. int ara [] = {1, 4, 6, 8, 9, 11, 14, 15, 20, 25, 33 83, 87, 97, 99, 100}; Now tell me how much the value of low and high-? low = 1 and high = 100? But here's the catch right there is a little problem. We do not have to find all the numbers here, but have to find in the array index. Because the array is an array of binary search is inadeksagulo sequence. Here ara- lowest index of 0 and a maximum of 15 indexes. If we let the two variables - low_indx = 0; high_indx = 15; Suppose that the number of T 97. num = 97; Many of you may be thinking, num the number is not on the ara- What will happen then? We also take a look. If the number is not found, then it must be extended to our program. Since the task of finding us again and again that, we will have to use a loop. We will be searched and the number of the loop when (or if you are sure that the numbers are not there), we'll be out of the loop. We tried to write binary search program. The program is very simple. Lupati will continue until you find the number, because we wrote while (1) and 1 all the time, really. But if the number is not on the ara- lupati will continue and will not stop in our program. So it needs to be a system. Well, we understand how that number is on ara-? You have already noticed that we were to continue the search in the simata half. If this trend continues, there will be a time within the range. And will be equal to the value of high- and low. Since each of the low- and high- value is increasing at decreasing the value, equal to the yebara low and high, the next time will be better than the quality of low- to high- value. And we understand that the number could not be found. So long low <= high as lupati run. I was out of the loop if low> high, then I know that the number could not be found, and found not only the number and value of bujhaba ara [mid_indx]. You will work in a different function for the write binary search.

[Programming book CHAPTER Nine] string (string).

Bengali word meaning the string you know, they have no reason to panic, it is not hard to tug at the string programming. Those of you who may have little knowledge on the type of string theory, the term has come to them. However, there is no reason for concern. One or more of the character string is made. In simple words, the character type array of strings. However, the use of programming so much that it is no coded string is considered to be a separate data type. However, with an array of type char string in C, we'll work on. Thus, we can declare the string. Four declaration is actually the same thing. At the end of the Null character ('\ 0'), the compiler know where the end of the string. The third example of the separate elements of the array was written, were written together. Null character in the compiler itself will sit. The fourth example is a little strange. Here are the names that have been used to figure out the pointer (pointer). The book detailed discussion of such things, but we're not going to use it occasionally. Notice here that printf- inside% s has been used to print the string. The array at the end of \ 0ta came when not in use. It should be understood that the present kampailaragulo. The program for free. Then for the following program. What difference do you see in the output? What is the reason for the difference? What's the difference whether you run it, and the computer will understand the program. Because of the differences in the programs in one place, the string '\ 0' because there is a compiler for the strinta has ended. Then we write a program. All the characters in a string inside the capital (the capital letter or uppercase character) to be converted. However, we need to know a thing. In contrast to the computer using a number code for each character. According to the code, 'A'- of the standard 65,' B'- of the standard 66, 'C'- the standard 67 ... the' Z'- of the standard 90. So 'a' is 97, 'b' 98's ... the 'z' is 122. So any uppercase characters that we can determine whether this: if (ch> = 'A' && ch <= 'Z'), or if (ch> = 65 && ch <= 90). As for the lowercase letters: if (ch> = 'a' && ch <= 'z'), or if (ch> = 97 && ch <= 122). Now, if a character is lowercase, but the way he's capitalization? Way too easy. See an example: char ch = 'c'; ch = 'A' + (ch - 'a'); Here is his first to ch 'a' means of minus 'c' from 'a' minus (subtract 97 from the 99's). Difference 2. Now 'A'- however, let's you add the 2' C 'will be! Uppercase conversion program is now entering a Fellow at the lowercase-. Then start reading the book again. Notice here that the string (character array) to see how many of the elements that I wrote down and putting them straight length = 10. Now we will write a function to measure the length of a string! It is not difficult. A loop of string to each element of the test, and Null character ('\ 0') to be taken out of the loop, ie, '\ 0' will continue until the loop. The total length of the string will be run as many times as the loop. Programataya you see above scanf function has been used for the input and the input string is used for% s. yatati material scanf function takes as input, and returns the number. The return value is usually not necessary for us, so that the value using scanf, but we can not keep. When the input as we write two integers: scanf ("% d% d", & n1, & n2) ;. We want it this way, I could write: value = scanf ("% d% d", & n1, & n2) ;. If you see print quality of value- 2. while (1 == scanf ("% s", country)) line, which is what is happening, as long as the name of a country- being input with scanf, the function returns 1, the inner loop condition is true (1 == 1) , so the loop will continue to work. Another thing that a notice of country- did not use any of the & symbol. What's on in the program by entering the & country. However, any whitespace string is a problem with the use of% s characters (such as spaces, tabs, etc.) can not be, if scanf something that takes a string of characters. For example, if this is the input string, the latter, however, this will be the first scanf, scanf function call is then again, it is he who will take the input string. To avoid this we can use the gets function. This program will continue until you ctrl + z (ie z together and ctrl on your keyboard) Press, for Linux ctrl + d. ctrl + z or ctrl + d gets the function returns NULL. Another thing I noticed is that a char ara [100]; The maximum length of the string will have to be declared at the beginning of 100. Another thing. even though not actually used inside a function of two variables string_length. Now you do not need to be string_length function for loop while loop written using. Our next program will aim to concatenate two strings or pairs. For example, if a string is "bangla" and another string is "desh" However, with two pairs of "bangladesh" would make. You are not the first to declare stringulo: char str1 [] = "bangla", str2 [] = "desh", str3 [12]; Our goal is to str3 "bangladesh" hold. Some of the benefits would be if we could write: str3 = str1 + str2; But C can be added to the two arrays or strings. So that a copy should be str3 str1- ingredients, the ingredients of str2- str3 to copy. The program for free. What should be the output? bangladesh. But the output is desh. In fact, we've made a mistake. Now you should try to fix the error. Despite the efforts of at least thirty minutes, if you can not make a mistake to start reading the book again. Here we have the beginning, because i i- value of 0 to the index as we will use str1-. Who will use the index as str3- j j- of the standard is 0. Str1- copy of each of the ingredients are then str3 and the value of 1 if i and j- baracchi (i ++, j ++). After the end of the loop the value of i and j 6. Now the loop, we'll str2 a copy str3-. Now if i use str2- as the index, but its value at the beginning of the loop to be 0 again. We have it. But that's wrong with the j- value of 0. If the value of j- 0 str2- of the first (0-th) element of str3- first (0 th) as the material to be copied, but we do not want it. We want to be the first element of str2- seventh element of str3-. J- If the value can not be 0. Notice another thing. After being out of the loop end of the second chamber str3- '\ 0''ve assigned (str3 [j] = '\ 0';) so that strinta end there, the compiler can not understand it. Our next program will be compared between the two strings. That is, in the string of small, large, equal to diagnose. As in the case of>, <,> =, <=, == keys can be compared, in the case of the string is not in the system. But this is often the case, the string will need to be compared. Just as, in the case where the sorting of small to large or small in order to be sort (alphabetical ordering). What's the string of large and small? More than words can not explain why some examples, then you will understand. 'Aaa'- than' aab 'big. The 'ba' and 'ca'- the' ca 'big. In this program, we will write a function string_compare (), which would be a comparison between the two string will return 1 if the first one is bigger than the second, smaller will return -1, and 0 if both are equal. The return type of the function parameters will be two integers and an array of type char. The first elements of our work a- b- of the first element, a- b- with the second component of the second material can be compared to. Whenever any component of a- b- to be smaller than any of the ingredients, we can say that with a, b- smaller. So come out from the function returns -1. Similarly, when any element of a- b- to be larger than any of the material, with 1 out of the function will return the a, b- greater. But all of them are equal? Then we'll return 0. I know that the two strings are equal. Basic string discuss things. Interestingly, however, a header files are coded in C, whose name string.h and over most of the string-related tasks have been made for the function (eg: strcmp, strlen, strcpy, etc.). I work with you, to be made again, there is no reason to be sad, do not be angry with me. It's always important to keep learning the fundamentals, which will develop your programming ideas. Now we will write another program which will take as input a string (where there will be many words). 1000 will be the maximum length of the string. There will be one or more spaces between words. The output of each word as a separate line to be printed. Biramacihnagulo (punctuation) can not be printed and will be uppercase first letter of the word. Wipe with a lot of conditions. The program is very difficult. You can try yourself. Let's see now how it could not be resolved. The first thing, how do I? Do you know the space that will be input, scanf ("% s") can not be used. So we gets () will use. Being next to no character can have a word? As is known, we assume 'a' to 'z', 'A' to 'Z' and '0' to '9' will. The next question is, we tell when or how we'll reason that the program has been a sound? -For A variable we can. If the value is 0, then the name of the variable is_word_started do not start unnecessary words, when the sound of the standard, we will 1. Will sound again at the end of 0. When we see the word has begun (is_word_started- value of 1) the value of any of the characters 'a' - 'z' or 'A' - 'Z', or '0' - '9' is not in this range, then tell the end of term . Before you write, do not even try to program, so if you hope to be. I'll write the code to see if it will have to try it yourself before. Understand what the program is having a little trouble? It can be viewed later, even if the type of the computer immediately before the program, compile and execute. They are people who use Linux gets () the use of a warning from the compiler (warning) may have, and do not care. You can write anything as input. For example: This is a test .. What is the output? The output looks like this: This Is A What is difficult! Where is the test? Now your job is to investigate the mystery of the disappearance of test-. Then I'll explain the program. Strlen function for determining the length of the string you see in the program I've used. And for me to have to include the header file string.h. S- strinta as input in the auction. We have to declare an array of the word. Then I ran s- i = 0 to the length of the inside of a loop to check each and every character. if (s [i]> = 'a' && s [i] <= 'z') or with a lowercase tried it. However, the first letter of a word in lowercase letters to find out what it will do. If the first character to be down again capitalization. We did the test: if (is_word_started == 0) with. This is the true meaning of the word has not started, the first letter. So we will is_word_started- value of 1. The word [j] to s [i] - take the uppercase letter. Then one will have to increase the value of j-. else if (s [i]> = 'A' && s [i] <= 'Z') and else if (s [i]> = '0' && s [i] <= '9') of these two conditions We work within the same. s [i] the word [j] to make copies. So if you could write the two terms together: else if ((s [i]> = 'A' && s [i] <= 'Z') || (s [i]> = '0' && s [i] <= '9')), enter the following means of else- if and else if- the criteria had been lying. So s [i] - the inside of the characters can not be left in the word-. And if the word has already begun, it will end and the printed word to be. If this is not the start of a word does not need to do anything. Test- Did you solve the mystery? If you want to try a different way, and I now write the program (it has nothing to do with the test of mysticism told). I'll do for now, as I write the program so that it does not use the word ayaretii! Look a little thought. So we're not actually in the array without print. So there's really no need. Now try to understand the program and examine the various inputs. For example: This is test number 9.9 The string-related problems seem complicated, but in fact easy to see. He will practice skills such as problem-solving will be more.

[Programming book Chapter Ten] prime number.

A prime number (Prime Number) to mathematicians as a favorite, so much programaraderao favorite subject. At various times you will be able to solve problems of basic sankhyasankranta. Another way to understand it is important that the basic thing, the topic of this book, I've allocated a separate section. A prime number is an integer greater than the number who are 1 and divides it by the number 1 and will be just. A very simple thing. We have written a function of the parameters which determine the basic number is an integer number n. We function from n to n-1 up to 2 figures have tried to share with the help of a loop. If any of these numbers divides n, then we can say immediately that it is not a prime number and the function returns 0. And after all that you have seen any number divided by the number n is utterly unable to divide, then we can conclude that n is a prime number. The function of the return-to-1 Cor. We went to learn basic to evaluate! I felt that way when writing the program and it is a very simple way. Program at iphisiyenta (efficient) did not try to make. You can easily understand the matter. Give 2147483647 program as input. It takes quite a while to figure out that the prime number. 2147483647 to 2147483646 because the 2 is the number of failed attempts to divide. Program will iphisiyenta. Indeed, there has come an understanding of your head already. These are all the numbers from 2 to n-1 divided by 2 does not try to n / 2 is simply trying to share with the numbers. If you double the speed of the program will be. Another thing you may not notice. If the number is not divisible by 2 utterly, then divides it by the number of any other pair of the question. 2 apart from the other even numbers (4, 6, 8, ...), it is foolish to try to divide. Even with the number of divisibility test we can take at the beginning of the function. First, we have examined the value of n- is 2. 2 is given to the prime number n. Then we've tested do not even number n. If it is even, then n is prime number, only even prime number 2, which is the only test we have done at the outset. Then we have 3 n / 2 n is the number of all odds tried to share. Now you examine the program with different input. 2147483647 If you know that the speed of the program has increased more than ever before, but still feel a little time. My computer takes like four seconds. But I can not let so much time. The more you understand the math, they'll think of a way to speed up this program will be able to find out. It is for you to get the producers of n- n / 2 until the number of tests required. n- is simply the square root of the test. When n = pxq, p or q is equal to the square root of the number of the n- or smaller. We math.h header file to determine the root sqrt () function will use. Now the program will continue to examine the various inputs. Give a talk. There is a bug in programataya (ie wrong). Even if it is just to find out. Prime numbers to be able to find a lot of you happy? But we will not stop here and try. We now look for another way, the Greek mathematician iratosathenesa (Eratosthenes) today, two thousand years ago, this method was invented. The name of the sibha iratosathenesa (Sieve of Eratosthenes). Let's explain the procedure. Just in case, we'll get the number from 2 up to 40, all basic. Wrote all the numbers: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40. Now, watch, the first being the number 2 on the list. Now all multiples of 2 (2, with the exception that less than 2 baragulo araki) give out. If you have 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39. Now the second number 3 all multiples (more than 3 baragulo) Remove. 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37. Now, the list of all the multiples of the number 5 (with the exception of 5) Leave it alone. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37. The next number is a multiple of 7, but it is futile to try to find. Because of the square root of the number 7 is less than 37. So 7 gunitakagulo list that was dropped from the list of those already. Understand the cause of the problem? Gunitakagulo on 7-of-14, 21, 28, 35. 7 the number of times that the gunitakagulo are available with all 7 numbers are smaller than the one we already have in their gunitakagulo. Now it's time to implement. We'll use an array to the list. Let's suppose that his name ara. In such a way to create the array, so that a number of n- status (ie, whether or not basic) ara [n] can be expressed with. If ara [n] - the value is 1, then the prime number n ara [n] - If the value is 0, n is not a prime number. Imaplimentesanera ago ayalagaridamata type: Step 1: Let's say there are elements of the array n. At the beginning of the array elements of the standard 1 tall. Step two: 1, whether the value of each component of the array tested. If 1, then go to the third step. Step 3: The number of 2 m with the serial numbers and product quality will be the array elements of the number zero (0) tall. It is not that the basic mark. Here m- m- with the values ​​of those numbers may be smaller than or equal to the product of n-. I've used a function to indicate the status of each array, print_ara (). Now we see that you input before the sieve () function call, have created the array. And every time I do not, there is no worry, but if the input is n ara [n] - was one of the standard test, the value of 1 if the prime number n, n is 0, then it is not a prime number. Do you want to count the number of how many will be required to sit in the size-. Now there is an issue with the speed of the program. Very fast (fast). But your eyes are no longer a problem? Do you understand that the cost of the program is much more memory? Just in case, we have 100 million so far to find out whether the basic number, then we will need an array of 100 million. "Time does not save memory, programmers often difficult to read. In case of problems, we can reach a solution between us. n- of the highest value to the value of its size- can take root. If you are called, n- maximum value of 100000000 (ten million) can be up to 10000 then the square root of the sieve to figure out the functions that primes. What will you do then? Well, I can not say anything, and you do not think that's right. We need to say another word. But replaced by an integer of four bytes, where one byte is a character. Instead of using an array of integers, so the characters are one-fourth of the cost of memory can bring it down. So we actually do not need an array of integers, the array will have only two values ​​0 or 1. In addition, there are several ways to further my writing sieve functions to increase efficiency. One of the qualities rather than being added. You try to do it.

[Programming book Chapter Eleven] array once again.

Do you remember writing programs for teachers of mathematics? The array of programs that we wrote three students out of the total number of tests for mathematics. If you do not mind, take a look at the program. We had a number of tests in a temporary array, the temporary array to another test number, the number of final exams is another array, and an array of the total number - have used a total of four arrays. So now the whole school is to write programs for the diagnosis of the results, but all the students of the class of the array to be used for testing all of the trouble of going to work. Lyanguyejei multi-dimensional array, so almost all the programming arrangements. So far, we've used the array, the array had all the dynamism. The program is now a little different way we write, using a single array. Let's say for the time being to reduce trouble in class ten students. I am writing to their numbers in the table below: Roll: 1 Roll: 2 Roll: 3 Roll: 4 Roll: 5 Roll: 6 Roll: 7 Roll: 8 Roll: 9 Roll: 10 First terminal exam 80 70 92 78 58 83 85 66 99 81 Second terminal exam 75 67 55 100 91 84 79 61 90 97 Final exam 98 67 75 89 81 83 80 90 88 77 Total marks Total Marks row of empty houses, because they have not yet calculated. First Term Examination 25%, 25% the second periodic testing and final exams will have to find 50% of the total number by adding the numbers. Now, on to our table to keep their numbers were 4 rows (row) and column 10. The programs we have written before, the first for an array of rows, one for the second row, third row and fourth in a row for the use of an array. Now I use a 2-D array (two-dimensional arrays). 2-D array to declare the rule is: data_type array_name [number of rows] [number of columns]; If it marks the upper chakata want to keep a 2-D array, but would write: int marks [4] [10]; Now, in the first row of the array of the marks [0], the second row marks [1], the third row marks [2] and the fourth row marks [3]. The marks [0] [0] is the first column of the first row, marks [0] [1] the first row of the second column, marks [0] [5] The first row of the sixth column, marks [1] [0] is the first column of the second row, marks [2] [3] is the fourth column of the third row. I hope, understand. Now tell me, which roll number 10 on the periodic testing of its second number is a house? The marks [0] [0] into the car and there is no test number? marks [0] [0] - 1 in the roll number of the first periodic examination and marks [1] [9] - will roll in the number of 10-second periodic testing. Thus, we can keep the array numbers: int marks [4] [10] = {{80, 70, 92, 78, 58, 83, 85, 66, 99, 81}, {75, 67, 55, 100, 91, 84, 79, 61, 90 , 97}, {98, 67, 75, 89, 81, 83, 80, 90, 88, 77}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; Here you have noticed that we actually have an array of arrays in four dynamism. marks [0] in the first frame on the number of examinations, marks [1] - the second periodic testing numbers, marks [2] - The number of final exams and marks [3] on the total number (since it is still not calculated, so the 0 I write).

[Programming book chapter twelve] binary number.

We are reckoning for the life of the dasabhittika (decimal) number system is used. Using the computer duibhittika or binary (binary) number system. Dasabhittika have the ten digit numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and two binary 0 and 1. The binary number system in this chapter we will look at some basic things and from binary to decimal and decimal to binary conversion of fact. Desimale we count like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ... 19, 20, 21, ..., 98, 99, 100, 101 .. .. Look, when we are on the right side of the room (single room) using ten digit commit, he left the house early the value of the sums one walk (if you do not have to add 1 to 1 to 0, and that tall or what, but the 9 and 09 the same thing, so the next number of 09 to 10), the home of the decade from 0 to 9, using the address of the amendment to the sums of the century house (and if you do not tall or 0 to 1, with 1 to add more) . We'll count the same binary: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011 .... Only two of the address, so the two on the left side of the drawing room, with one to replace or add 1 to 0 (on the left side, we can not arbitrarily impose zero). However, units of the binary system we have, of late, century houses, one would say that tens of thousands of houses, two rooms, four rooms, room eighties. Why so? Think a little. Desimale it takes 10 to enter the address, enter the 100 three, four in 1000, to write, so write in binary two-two (10) to enter the four-three (100), enter eight to four (1000), sixteen to enter the five (10000) address to use. Desimale right of the first address (100 = 1), the unit cells, the address (101 = 10) of the decade, a third address (102 = 100) of the century, but also the right of the first binary digit (20 = 1) by the house, The following address (21 = 2), the two houses, then (22 = 4) of the four houses, like this. Dasabhittika example of addition, subtraction, multiplication, and can be shared, can be done in binary. In fact, you can not add, but the rest does not matter. Again these are binary fractions, but I'll only talk about integers. Accounts of the original inclusions are: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 10. As Decimal calculation, 1 + 1 on the case, either (10) first came to zero, is the one, after I wrote it. 101 + 101 = How many? First, add another room, 1 + 1 = 10. So, sit in the house by the sum of 0 and remained in the hands of 1 (carry). Now the two house, 0 + 0 = 0, so this will add 1 to 0 with the hand. 1. If the sum of the two to sit in the house. Now, if we get four houses, 1 + 1 = 10. There is nothing at hand (there is no carry). So it will be a 0 and 1 will be a four room house eighties. Sum: 1010. 1011 + 1011 = Tell me now, how much? Continue by adding the sum was 10110, then you made a mistake somewhere in the addition. Decimal would be calculated as in the case of substitution. 0 - 0 = 0, 1 - 0 = 1, 1 - 1 = 0, 0 - 1 = 1. The last note, and 23 - 15 at the time, what do we do? The 3-in-1 left a legendary assume (or borrowed 1), and 13 - 5 = 8 impressed. And instead of a loan made, it adds the value of the home 1. So binary 0 - 1 to 0 in the left one time, the number of 10 (two), these two will have one-to-one elimination. The next one will have to add a room (with the number being subtracted). 110 - 101 = How many? Excluding one-room from 0 to 1 is 1, and 1 has to borrow. So the two houses of 101 will add it. If the house between 1 - 1 = 0, four home 1 - 1 = 0. So the difference will be: 001 or 1. If you can add and subtract times-there is no reason why we can not share. Decimal as a rule. However, the number of decimal digits, we place the sum of the fixed address, such as x 10 can enter, the binary digits x 2 specific address can be written as the sum of the sums of the US. For example: 1903 = 1 x 103 + 9 x 102 + 0 x 101 + 3 x 100. Binary: 10110 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20. In English, it's called Exponential Expression. If you want to find out the value of any binary now desimale, the first to enter the binary number in the form of exponential expressions. Gunaphalagulo desimale then be calculated. See the example below: 10110 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 = 1 x 16 + 0 x 8 + 1 x 4 + 1 x 2 + 0 x 1 = 16 + 0 + 4 + 2 + 0 = 22 10110 = decimal 22 is binary. We do not have any programming for a long time, let the value of the binary number to decimal wrote a program. It has become known method. Now the important question is: What would I read binary numbers? We can use string. char binary [] = "10110"; int len ​​= 5; 5 // string length. int decimal = 0; // We have not yet calculated, so grabbed the decimal value is 0. We have the binary numbers in a loop with the amount of 2 times the amount that the US will join with decimals. The first character of the binary [0] on the '1' in the position of how are you? 'S position 4. The ensuing substantial decrease in the position of one of the standard, the position at the end of the digits 0. We are out of the loop when the decimal value of the binary number, we will get. Here, I've used the pow function. It is stated in the header file math.h. ab- out the value of the pow (a, b) be required to compile and execute hayaprograma. If you give input to 10110, then how come output? He should come to the output of the output of 31 to 22. If we made a mistake somewhere. You try to find the error manually. We are in the pow (2, position) multiplied by a binary number to the amount of the position-, we forgot it. In other words, we would write: decimal + = binary [i] * pow (2, power); I do notice a thing? 10110 Home of the amount by the end of our array of characters, and the first character of the array is the amount of sixteen houses. Thus the number of array ['1', '0', '1', '1', '0']. So binary [0] - triple with pow (2, 4), binary [1] - triple with pow (2, 3), ..., the binary [4] - with the triple pow (2, 0 ). Now, with the right program, then run. What is the output for the input of 10110? I can see the output Decimal value is 1510. Where was the mistake? I did all right. Again, you're not going to bother you? Test cricket needs such patience, game programming, so patience. The error that the decimal + = binary [i] * pow (2, power); There is no doubt that this statement. This is because we have changed a bit. Notice, binary [i] - the value of '0' or '1' (ie character '0' or 'Character' 1 '). Now the computer '0' understands that 48 of the '1' to understand 49. Jhamelata been here. Now this '0ke 0 and' How does she usually react 1ke 1? '0' - '0' = 48 - 48 = 0. '1' - '0' = 49 - 48 = 1. Is not that great idea? We are binary [i] writing (binary [i] - '0') to write the trouble. Now the program will work properly (unless you made a mistake if new). Now we look at the binary to decimal conversion. Show an example of the process. Who will have to convert binary is just 95. Now we have to find the maximum value of n-, where 2n <= 95. Paoyaragulo either 1, 2, 4, 8, 16, 32, 64, 128, .... Here we see the 64 <95 or 26 <95. 6. If the value of n-. And our seven-digit binary number (0 to 6, a total of seven digit). Since 64 <95, so this number can be taken. If sixty-four cells (first from left to right or from right to left in the seventh) to 1 (1xxxxxx). Now the value of n- 1 kamai. 64 + 25 = 64 + 32 = 96, which is greater than 95. Therefore, it can not be taken. So thirty-house 0 tall (10xxxxx). Now once again the value of the kamai n-, n-'s value is now 4. 64 + 24 = 64 + 16 = 80 <95. So will house sixteen 1 (101xxxx). Now the value of the kamai n-, n = 3. 80 + 23 = 80 + 8 = 88 <95. So, sit in the eighties cell 1 (1011xxx). And similarly, n = 2-for 88 + 22 = 88 + 4 = 92 <95. 1 four rooms sit (10111xx). Then n = 1, 92 + 21 = 92 + 2 = 94 <95. Two rooms 1 (101111x). Now, n = 0, 94 + 20 = 94 + 1 = 95. So one house 1. So the binary number 1011111. You are now entering the program to convert the binary number to any dasabhittika Fellow and examine the different standards. We'll do the same in a different way now. See the table below: Quotient Remainder 95/2 47 1 47/2 23 1 23/2 11 1 11/2 5 1 5/2 2 1 2/2 1 0 1/2 0 1 Then the remainder of the column to its own digits in order from the first binary number, we'll be getting lekhalei: 1011111. We'll do it as long as they are not part of the quotient 0 am. Binary to decimal conversion code in this way, you break down. If the code is not the transformation of the main functions that a separate function.

[Programming book chapter thirteen] some programming issues.

In this chapter we will look at some simple problems and try to fix it. Our first problem is to create a variety of shapes.

[Programming book chapter fourteen] to end

We have moved in the last chapter. If you're reading the earlier chapters properly, look at the examples on your own computer, in any program you are and whenever I have to enter it manually, they are trying to write himself, then congratulations to you! Are you ready to learn programming. If I could tell you, but you will have to learn programming liked, I liked, but it does lie? Programming agendas. The test results can be much better to memorize, memorize them and even college-university programming exam is a good number. However, a good number of these have nothing to do with the fact of being a good programmer. Being the kind of programming skills (skill) and the efficiency can be achieved only through regular practice. You do not need to be good for students, there is no need to become genius. People need love programming. When you sat down to programming'll forget about dinner, the night began with a programming problem, and after a while to see the light of dawn bloom, nor forget the bathroom sandals can leave the class, then know that you're going to become a programmer. Now, should you read the book again and again with the programs. If you want to learn more, and then C-in-C can read any book. If you are interested Programming Contest C Plus Plus (C ++), you can start to learn from a book. Java (Java), C Sharp (C #), PHP (PHP) or Python (Python) can learn. Some sikhatei burden will not be closed because now you have mastered the fundamentals of programming have made. I wrote a sequel to the list of books and websites. One of the things that need to be a skilled programmer 1) one or more Programming Language command, Ii) skills to good use in an IDE, 3) clear ideas about fundamental aspects of programming, 4) The math and logic skills, 5) oriyenateda Object Programming (OOP- Object Oriented Programming) skills, 6) basic knowledge of data structures and algorithms and the ability to apply it, 7) communication skills (Communication Skills), 8) to solve problems in a short time on internet sites or skills to quickly learn a new subject, 9) the mentality of having to take a back problem, 10) love for programming. Programming your life to be happy, be happy in your own life, the lives of people around you, because you will be happy. Greetings to all.