--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:
With this activity I learned to use \t for add
Continue reading "Quiz 6"