Today I worked on case study 7 for my Unix / Linux class and learned about the time based job-scheduler named 'cron' and I also learned about IRC bots. As it turns out 'cron' is a very useful tool and can be used to automate processes or jobs that need to be executed at certain intervals such as performing a file system integrity check or checking for package updates. IRC bots can also be a useful tool to utilize as I found out. Following the instruction from the case study I was able to download, configure and launch the 'phenny' bot. Configuration was pretty straight forward and simple. All that needed to be done was edit the default configuration file and enter the IRC server and owner details. After that it was as simple as launching the bot and let it connect to the IRC server. Bots also have a very useful purpose as they can be configured with extra modules to make them perform different tasks such as checking the weather in a specified location, getting the current time from an Internet time server, etc. Both of these things can be very useful when utilized properly.
This past week has by far been the toughest yet in my C/C++ class. I began work on project 2 earlier in the week and I have been banging my head ever since. I don't know if it's because I am not “absorbing” what I am learning in class, or if it's just the way I am trying to write the my program. I just seem to be having a really hard time actually figuring out what needs to be done in my code to accomplish the task. I have been in the class IRC today for almost 12 hours straight and while it definitely helped a lot, I feel that there is still something that I am either not understanding, or overlooking, or something. Right now I have a partial program with 2 functions that do not properly work and I am at a loss as of right now as to what I can try next. I guess I will sleep on it tonight and start fresh tomorrow and see what I can accomplish.
A lot has happened since my last entry. I have been working on project 2 and with help from the IRC and the instructor I finally have the first two modules working properly with the exception that any numbers used must be padded with zeros. I am now working on the multiplication and division functions but I am finding them difficult also. I know what has to be done in the multiplication function but when I implement the problem in code it doesn't work. I think my logic is flawed and will have to continue working on and to find the problems. Switching gears we have been talking about classes and inheritance. I class this past week we created a small program that uses classes. The program taught me how to write functions into reusable files and how to compile multi file programs into executable code. Also out instructor has saved us once again and combined project 2 and project 3 together so now I have more time to figure out the problems with my code. Well thats all for now, back to work on the project.
Well its the last day of March and getting closer to spring break. Still working on project 2/3 and while I am making progress I am still having issues with the actual math functions. This past week the instructor gave us class time to work on our programs along with time to work on things we were having problems with in class. Unfortunately I have decided to drop my Unix class so I am able to put forth more effort in the C/C++ class along with my other classes. Well thats it for now, I know its short but I have other things to attend to (the project mainly). Will make an update later as to what happened with it.
Typedef allows a user to define there own identifiers. These new identifiers can be used in place of type specifiers such as int, float, and double. A typedef declaration doesn't allocate any additional storage and the names defined using typedef are not new data types rather they are merely synonyms for the data types they represent. When an object is defined using a typedef identifier, the properties of the defined object are exactly the same as the original data type they represent.
Enum short for “enumerated data”. enums allow a user to define a fixed set of words that a variable of type enum can use as its value. The words are assigned integer values by the compiler so enum values can be compared.
A union is comprised of a collection of variables of different types, just like a structure. However, with unions, you can only store information in one field at a time. Once a new value is assigned to a field, any existing data is overwritten with new data. The use of unions can save memory if you have a grouping of data and only one of the types is used at a time. The size of a union is dependent on the size of it's largest data member.
Type casting also known as type conversion is the concept of converting one data type to another data type. For example you might have a float data type that needs to be an int data type for use in some part of a code.
Below is an example of Type Casting in C.
#include <stdio.h> int main() { /* The (char) is a typecast. Its telling the computer to interpret the 32 as a character, not as a number. The output of will be the ASCII equivalent of the number 65 (It should be the letter A for ASCII). Note that the %c below is the format code for printing a single character */ printf( "%c\n", (char)32 ); getchar(); }
Scope refers to the way data is declared and accessed within a program.
Global scope, found in C++, occurs when a name is declared outside of all blocks, namespaces, and classes. The name is accessible anywhere after its declaration.
Local scope also know as Block Scope, occurs when a name is declared within a block. The name can be used within the block that it was created in and any child blocks that are enclosed within the parent block.
File scope, found in C, occurs when a name is declared outside all blocks or classes. The name is accessible anywhere after it is declaration.
Below is a demonstration of Scope.
/* * Sample code block */ #include <stdio.h> void test{int} //This function prototype has file scope because it is defined outside any block, namespace, or class. int main() { int z=0; //This variable has been declared within a block of code this giving this block scope. return(0); }
Selection structures also known as control structures are special structures found in the C and C++ programming language. These structures allow for one of multiple possible scenarios to occur based on the value of a variable.
Below is an example of an If structure.
/* * Sample code block */ #include <stdio.h> int main() { int a; int b; int c; if (a > b) { c = a * b; } else { a = b * c; } return(0); }
Below is an example of a case/switch structure.
/* * Sample code block */ #include <stdio.h> int main() { char a; char b; int c; int d; switch(d) { case 1: statement; break; case 2: statement; break; case 3: statement; break; } return(0) }
Logic can be defined as the non-arithmetic operations performed by a computer, such as sorting, comparing, and matching, that involve true-false decisions.
Operators can be defined as symbols that are used to perform operations. There are 8 logic operators available in the C and C++ programming language and those are !, &&, ||, ^, !=, &=, |=, ^=.
The “!” notates logical “NOT”
The “&&” notates logical “AND”
The “||” notates logical “OR”
The “^” notates logical “XOR”
The “!=” notates logical “NOT_EQ”
The “&=” notates logical “AND_EQ”
The “|=” notates logical “OR_EQ”
The “^=” notates logical “XOR_EQ”
Arithmetic is the portion of mathematics that deals usually with the non-negative real numbers including sometimes the transfinite cardinals and with the application of the operations of addition, subtraction, multiplication, and division to them
Operators can be defined as symbols that are used to perform arithmetic operations.
Below is an example of arithmetic in C along with some of the basic mathematical operators available in the C language.
/* * Sample code block */ #include <stdio.h> int main() { int a=20; int b=5; int c=0; a + b = c; //Add a - b = c; //Subtract a * b = c; //Multiply a / b = c; //Divide a % b = c; //Modulo(Remainder) return(0); }
A structure can be defined as a collection of variables that can be accessed under one variable name thus providing a way to keep related information grouped together.
Below is an example of structures found in the C language.
/* * Sample code block */ #include <stdio.h> int main() { int t; struct //This keyword tells the system a structure is being declared. { char name[30]; char street[40]; char city[20]; char state[3]; unsigned long int zip; } addr_info; addr_info.zip = 14830; //Here the zip element is accessed and the zip is written to it. gets(addr_info.name); //This statement passes a character pointer to the beginning of name. for(t=0; addr_info.name[t]; ++t) putchar(addr_info.name[t]); return(0); }
Namespaces are an optionally named scope. Names can be declared inside a namespace just as you would for a class or an enumeration. You can access names declared inside a namespace in the same manner you access a nested class name by using the scope resolution (::) operator. Namespaces however, do not have the additional features that classes or enumerations possess. The main purpose of namespaces are to add an additional identifier (the name of the namespace) to a name.
Below is an example of namespaces as found in the C++ language.
/* * Sample code block */ #include <iostream> using namespace std; namespace primary { int var = 5; } namespace secondary { double var = 3.1416; } int main () { cout << primary::var << endl; cout << secondary::var << endl; return 0; }
What is the question you'd like to pose for experimentation? State it here.
Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.
Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.
State your rationale.
How are you going to test your hypothesis? What is the structure of your experiment?
Perform your experiment, and collect/document the results here.
Based on the data collected:
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.
What is the question you'd like to pose for experimentation? State it here.
Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.
Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.
State your rationale.
How are you going to test your hypothesis? What is the structure of your experiment?
Perform your experiment, and collect/document the results here.
Based on the data collected:
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.
Perform the following steps:
Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.
Evaluate their resources and commentary. Answer the following questions:
State their experiment's hypothesis. Answer the following questions:
Follow the steps given to recreate the original experiment. Answer the following questions:
Publish the data you have gained from your performing of the experiment here.
Answer the following:
Answer the following: