Quiz-Fibonacci code!

--Originally published at Programming the city

Hello there! As usual, I  post the codes which the teacher tell us to do.

Today I created the Fibonacci sequence, but the user has to introduce the limit or the number which will be the limit of the serie.

This code was a Little harder than the others for me, but with the help of my good friend and classmate Gustavo Hinojosa, I could finally did it.

Here is the code

a

 

And here is the result:

a


#Quiz 06

--Originally published at It's me

This quiz was about creating 5 programs… But we had to copy the first five exercises from this website and make them work. They were kind of easy, I enjoyed working on it. The only one that I had trouble working on was the second program, basically consisting of converting a char to an int or a float, or viceversa. I found out it was easy with the help of internet and my classmates. Here are my codes and running in a slideshow:

Haga click para ver el pase de diapositivas.

Original header image recovered from:  https://www.flickr.com/photos/lyonora/2553342492/in/photolist-4TCxLq-o1hUE-4nFTB6-62DNq-6boydm-6xixp7-4ocshf-V7e58-2dwCN-4pZ4GJ-6mp8EY-baeZjP-7kuz2S-4WdCTh-7kaEY-xLUqv-6ojgRs-4Pe7z-cvLyLG-95ZcHD-6ojh25-PWi7X-73AM5f-is1M9-HwBe-PyrEu-dPPcN-dM3mJ-bY2MWf-cP3Wi-ehEemC-Jne1Gy-SSnJiF-SSSzB4-nsWjTr-rvwykT-4JTs6B-arbtDz-doDmhe-6kDAjS-naBjky-naBoL9-7xRMxr-6kDCvb-9Qekaz-6kDGpC-8LpE9-mJmYyn-nMRm7i-52u6Xs


Quiz 6

--Originally published at Tec Life

In order to do this quiz I search the information in one site: http://www.cplusplus.com/reference/

We have to solve 5 problems; the first one was about correcting one program and run it, so I use two new libraries in order to solve the program and start testing and rewriting the program, and the final result was this:captura-de-pantalla-2017-02-13-a-las-09-08-45captura-de-pantalla-2017-02-13-a-las-09-09-01

The second problem was about writing a program to read in a character, an integer, and a float, and print out the values, then cast to other types; so that the interaction with the user is something like the following:

captura-de-pantalla-2017-02-22-a-las-21-25-57

captura-de-pantalla-2017-02-22-a-las-21-26-06

The next program was only about to the following pattern:

                        C
                      i   I
                    s       s
                  b           b
                e               e
              s                   s
            t s e b s i C i s b e s t

 

So the only thing that I have to do was print the letters in that order and that was allcaptura-de-pantalla-2017-02-13-a-las-09-42-22

For the fourth problem they ask us to write a program to read three ints and to print them in ascending order, so the most easy thing to do was using a lot of if and else to solve this problem:captura-de-pantalla-2017-02-22-a-las-21-31-32

captura-de-pantalla-2017-02-22-a-las-21-31-43

And the last problem they ask us to write a program given the following rules, write a program to read a year (4 digit integer) and tell whether the given year is/was a leap year.

  1. There were no leap years before 1752.
  2. If the year divides by 400 then it is a leap year.
  3. All other years that divide by 100 are not leap years.
  4. All other years that divide by four are leap years.

So I use the main if as 1752 because if that wasn’t true then the year will be normal, the I use another if to say the conditions when the year will be

captura-de-pantalla-2017-02-23-a-las-08-29-54
captura-de-pantalla-2017-02-23-a-las-08-30-04
Continue reading "Quiz 6"

One at a time

--Originally published at Ken's Disciple 01

Picture by Unsplash Unsplash

 

Hello everyone! This Blog is about Quiz06, probably the one with most things to do and the “hardest one”, but don’t worry, once you try it you’ll see it ain’t that hard.

There are 5 exercises in this quiz, let’s start one by one. You can check the exercises and more if you want to practice on this web page.

NOTE: at the end of the Blog you’ll find the links for all the codes of this Quiz.

  1. Type in the following program and run it:
    #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;
    }

For this example you HAVE to read the notes that ken gave us:

Notes

C++ keeps changing and runs different on different machines. For the first question you may want to use printf instead of cout to format the printing, check out the printf reference here.

Note that you will also need to include <stdio.h>

printf will also complain that you are not passing an int to the %d so perhaps you want to cast the sizeof value to an int like this:

int(sizeof(c)*8)

In this notes are the clues for this example: first knowing about

Captura de pantalla 2017-02-16 a la(s) 14.24.20.png
Captura de pantalla 2017-02-16 a la(s) 14.24.59.png
Captura de pantalla 2017-02-16 a la(s) 14.25.27.png
Captura de pantalla 2017-02-16 a la(s) 14.26.47.png
Captura de pantalla 2017-02-16 a la(s) 14.34.26.png
Captura de pantalla 2017-02-16 a la(s) 14.34.51.png
Captura de pantalla 2017-02-16 a la(s) 19.26.07.png
Captura de pantalla 2017-02-16 a la(s) 19.26.38.png
Captura de pantalla 2017-02-16 a la(s) 19.26.47.png
Captura de pantalla 2017-02-16 a la(s) 19.26.55.png
captura-de-pantalla-2017-02-16-a-las-19-00-05
captura-de-pantalla-2017-02-16-a-las-19-00-20
captura-de-pantalla-2017-02-16-a-las-19-00-29
captura-de-pantalla-2017-02-16-a-las-19-00-39
captura-de-pantalla-2017-02-16-a-las-19-00-47
Continue reading "One at a time"

Vamos por partes… Quiz #6

--Originally published at Adal´s Blog

Esta ves el quiz nos llego algo extenso, con 4 actividades individuales



El primer ejercicio dice que solo copiemos las lineas de código y lo hagamos correr para saber el tamaño de almacenamiento de nuestra computadora 

La segunda parte es la que considero que mas trabajo me costo hacerla

El 3 no se compra con nada al segundo XD


El cuarto lo resolví solo utilizando if anidados y algo de lógica

y por ultimo, utilizando if´s  y condiciones anidadas


Paginas de ayuda:

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

#Quiz06

--Originally published at Solving Problems with Programming

PICTURE OF AUTOR

THIS IS THE #QUIZ6 (WEEK 6) WHOSE OBJECTIVE IS PRACTICE THE CODES THAT ARE MADE IN C++. COVERING #MASTERYTOPIC03

This #QUIZ06 are 5 exercises to help me practice my skills. At present, I’m considering the following as projects: 1,2,3,4,5. These are designed to stretch me gently.

At doing this quiz I learnt that the language C++ keeps changing and runs different on different machines. For the first question I had to use the old command printf instead of cout to format the printing and I had to research the reference in this page: Reference for exercise 1 with also including the old library include <stdio.h>

  1. Exercise 1 Type in the following program and run it:
    #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;
    }

Pictures of the quiz6 exercise 1.:

primera

LINK IN GITHUB:Exercise 1 in Github.cpp

Also is in here:

#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;


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:"
<< 
segunda
tercera
cuarta
exercise3
octava
quiz6v4
quiz6v4444
decima
decima2
quiz6v5
Continue reading "#Quiz06"

Quiz 6

--Originally published at Loading…

I decided to make Quiz 6 before the Activity 7, because it seemed to me would be simpler, also the quiz is for this week. BUT this quiz was too different that the others, it was more time-consuming  and really tested me.

We had to do the first 5 exercises of this page, and they were a little bit different from what normally we do. I did them in disorder, but here they all are.

Activity 1, run a program.

This one was one of the most difficult, and not precisely because it was too hardcore, more like, it wasn’t running correctly through the fault of a parenthesis in the wrong place.

So, the activity was:

Type in the following program and run it:

#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;

First I completed what it was needing to the program, added the libraries & , wrote using namespace std; (as always), and wrote int before the main. Then I substituted the cout << endl << for printf(. Later, in order to make sizeof( )*8 works Ken said that we need to wrote int( before. And that’s all, this is my code:

quiz6-1

With this activity I learned to use \t for add

quiz6-2
quiz6-3
quiz6-4
quiz6-5
whatsapp-image-2017-02-14-at-10-54-35-pm
whatsapp-image-2017-02-14-at-10-57-10-pm
Continue reading "Quiz 6"