Fibonacci series- quiz week 8

--Originally published at Programming course

5978831814_69fd0027af_o fib

 

In this assignment we saw the number series of Fibonacci, which is basically a mathematical explanation to many things in nature, such as the spirals found in flowers, plants, etc, and the numerical sequence in them.  In the program we made, using a loop I told the user the series. This is the code I used.

And if you want to know more about Fibonacci in art, you can click here and there is a great  easy slideshow.quiz8quiz8-atom

Pictures used:

https://www.flickr.com/photos/snlsn/

http://www.imagekind.com/Hokusai-Meets-Fibonacci-Golden-Ratio_art?IMID=87c29c1e-7700-45a0-ae29-6b7ddcbf7e48


Quiz 06 part 1

--Originally published at Programming course

So the problem said that we should write this code:

#include 
main()
{ /* PROGRAM TO PRINT OUT SPACE RESERVED FOR VARIABLES */
	char c;  
	short s;  
	int i;  
	unsigned int ui;  
	unsigned long int ul; 
	float f;
	double d;  
	long double ld;  
	cout << endl 
  	     << "The storage space for each variable type is:"
	     << endl;
	cout << endl << "char: \t\t\t%d bits",sizeof(c)*8;  //  \t means tab 
	cout << endl << "short: \t\t\t%d bits",sizeof(s)*8;
	cout << endl << "int: \t\t\t%d bits",sizeof(i)*8;
	cout << endl << "unsigned int: \t\t%d bits",sizeof(ui)*8;
	cout << endl << "unsigned long int: \t%d bits",sizeof(ul)*8;
	cout << endl << "float: \t\t\t%d bits",sizeof(f)*8;
	cout << endl << "double: \t\t%d bits",sizeof(d)*8;
	cout << endl << "long double: \t\t%d bits",sizeof(ld)*8;
}

And then just run it. It was easy because it was just adding stuff like an “int” before the “main()”. The problem began with the couts , but all I had to do was to erase the “%” and the “d” in every line and that was it.

 

quiz6-1 quiz6-1-2

WSQ03-Pick a Number

--Originally published at Programming course

In this program we had to make a random number and the user needed to guess it. If the number was to high or low, the program will tell.

First I made the random number called nu1.

Then I asked the user to guess and using if, I told the user if the number was higher or lower than the random one and made them choose again.

When they guessed the correct number I asked if they wanted to play again and that was it  ?

wsq03-atom wsq03-terminal

WSQ02-Temperature

--Originally published at Programming course

The assignment was about asking for a temperature in Fahrenheit and with a formula convert it to Celsius, then tell the user if the water will boil or not.

What I did was to ask for the number, then apply this formula: C = 5 ∗ (F − 32)/9. And finally using an if, tell the user if the water boils or not (Temperature in Celsius>=100 it boils)

wsq02-atom wsq02-terminal

WSQ01- Fun with numbers

--Originally published at Programming course

So the assignment was to ask the player/user (¿?) for two numbers, and our job was to create a program that could sum, substract,multiply, divide and give the remain of the division.

  1. First I asked for the two numbers
  2. Then I declared the variables (Using int for the two numbers, the sum and the substraction and the multiplication and using double for division and remain because they can be numbers with decimals)

And the formulas I used were:

  • sum: a=x+y
  • difference: a=x-y
  • multiplication: a=x*y
  • division: a=x/y
  • remain:x%y

And basically that’s it ?

wsq01-atom wsq01-terminal

Quiz 04

--Originally published at Programming course

So during class I started my code and I thought I was done but the time was over, so as soon as I got home I started compiling my program, but the trouble started. I had many error and the program couldn’t run, so i went line by line trying to figure out what was wrong. At the end I only had one error about a “{” symbol, but if I moved it or delete it, I would have 19 errors, at the end I noticed I had a “;” before that “{” and I could finish.

captura-de-pantalla-2017-02-02-a-las-19-37-38 captura-de-pantalla-2017-02-02-a-las-19-37-53 captura-de-pantalla-2017-02-02-a-las-19-38-00