--Originally published at how not to program
This quiz is different from the others. It is divided into 5 parts. First one is to find errors in a given code.
The second part is about
The third part is about
The forth part is
The fifth step is
--Originally published at how not to program
This quiz is different from the others. It is divided into 5 parts. First one is to find errors in a given code.
The second part is about
The third part is about
The forth part is
The fifth step is
--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
And here is the result:
--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. --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:
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:
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 all
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:
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.
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
Continue reading "Quiz 6" --Originally published at Ken's Disciple 01
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.
#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:
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
Continue reading "One at a time" --Originally published at Adal´s Blog
--Originally published at Programming course
In this part of the quiz we had to create a program where it had to print out a kind of triangle. The only thing I did was to use a “cout” per line, using the spaces needed. And that was it
--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.
--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>
#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.:
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:" << Continue reading "#Quiz06"
--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.
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:
With this activity I learned to use \t for add
Continue reading "Quiz 6"