Homework 12: Estimating e

--Originally published at Let's CODE

This program will be capable of estimate the value of “Euler’s number” (e) and the user will give the accuracy expressed as a number of decimals. To calculate e, I declared three variables. One of them saves tha value of e, another counts each executation of the loop, and the last one (x), in each ocassion … Continue reading Homework 12: Estimating e

Homework 11: Go Bananas

--Originally published at Let's CODE

Now we are going to make a program that can find the quantity of BANANAS present in a text file. The word “banana” can be writen in any way, that’s why I opted for converting all letter in the document to lower case. I set a vector called BANANA with a size of 6, where … Continue reading Homework 11: Go Bananas

Homework 10: Babylonian Method

--Originally published at Let's CODE

This function will calculate a square root through the Babylonian Method. First of all, I would like to explain how the method works. You have to establish a first number that is “aproximate” to the real squareroot, doesn’t matter if that number is equal to one, because we are going to make some mathematical operations. … Continue reading Homework 10: Babylonian Method

Homework 8: Yo soy 196

--Originally published at Let's CODE

We are going to calculate the quantity of Lychrel numbers (natural numbers that doesn’t convert on palindromes after a serie of aditions, for example, 196 is a Lychrel number), natural and made palindromes that are present in a range of integer numbers given by the user. If we want to convert a non-natural palindrome to … Continue reading Homework 8: Yo soy 196

Homework 7: Lists

--Originally published at Let's CODE

This program will ask the user for 10 numbers and will be stored in a vector. Then, the user will be able to see the total of the sum, average and standard deviation of those numbers. A vector is very easy to use, you have to asign a type to the vector and give it … Continue reading Homework 7: Lists

Homework 6: Factorial Calculator

--Originally published at Let's CODE

Let’s make a factorial calculator! First of all, we have to know what a factorial number is. If you see a number that is accompanied by an exclamation sign, you’re seing a factorial number, that consists in a number multiplied by all the precedent integer numbers until reach one. For example, 6!= 65432*1 = 720. … Continue reading Homework 6: Factorial Calculator

Homework 5: Calculator

--Originally published at Let's CODE

This program will make some basic operations. It’s just like the program of the first homework, but using functions. We have to create 5 functions: sum, subtraction, multiplication, division and remainder. Each function must read two integer parameters (the same for each one) given for the user. Also, we have to declare another variable which … Continue reading Homework 5: Calculator

Homework 4: Sum of Numbers

--Originally published at Let's CODE

This program sums a range of consecutive numbers, between a given range by the user. It’s very simple to make, I will show you step by step how to make it. As usual, you need to call the necessary libraries and open the main function. We have to declare two variables for the bounds, one … Continue reading Homework 4: Sum of Numbers

Homework 3: Pick a number

--Originally published at Let's CODE

I have to say that this task is a little more complicated than the previous exercises, because it was necessary to use a special function to generate numbers randomly. This program was thought as a game, where the user have to guess a random number. I decided to give the user only five chances to … Continue reading Homework 3: Pick a number