Table of Contents

Daniel McKinney's Opus

Introduction

My name is Daniel McKinney, i am in the computer science program at CCC. I have already obtained an associate in Busn Admin. I spend most of my free time playing Xbox, GamerTag(iAM Beastly x), listening to music,or working out.

Part 1

Entries

Entry 1: Feb 21, 2012

I am learning a lot in c/C++ programming class. We have written a few simple programs that are allowing me to understand the syntax of the programming language. I am also learning some symbols and how to use them and what they do. Also i have found out that there is not only one way to go about writing a program, there are many different approaches. over all the class is fun so far, and i am learning alot.

  • learning the syntax of C
  • you cant write proper code without knowing the syntax of a language.

Entry 2: Feb 22, 2012

We wrote a program in C/C++ class that was pretty cool. First we put some random number into a text file. Then we wrote a program that would read form that file and then multiply those numbers by a predetermined amount and then write the product into another text file. We used both an “if” statement and a “while” statement.

  • first time understand the “if” and “while” statements.
  • loops are a very important part of programming.

Entry 3: Feb 23, 2012

Today we wrote a program in C/C++ that was basically a calculator(a calculator that could only add). We started the program out by declaring 4 int's. a,b,c,d. then we set them to 0.Then we used the sum function to add them all up for us after we prompted the user to enter 4 numbers.

  • using the sum function
  • i have not used any math functions up to this time.

Entry 4: Feb 28, 2012

Today in C/C++ Matt went over some of the problems that people were having with the secret agent project. It brought to light some things that i was having problems with. I got my program to cipher and decipher, but if the letter was a “z” then it would do a non alphabetic symbol.

  • ciphering a message
  • understand how chars work(they are numbers)
  • getting the cipher to not display non alphabetic symbols.

Keywords

cprog Keywords

(standard I/O)

Standard I/O

Definition

Standard In and Standard Out. Standard In is usually the key board, standard out is usually the monitor.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
printf("dafsf");
scanf("fda");
    return(0);
}

(Header files)

Header files

Definition

are files that are include in the main file, that have data in another file.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>

(pointers)

pointers

Definition

pointers are used to refer to a memory location of another variable, with out using that variable identifier.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
int *chicken
int main()
{
    return(0);
}

(variables)

variables

Definition

variables are place holders for a values that are in memory.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
int chicken
char turkey
int main()

(scope)

scope

Definition

place in the declaration where a variables name can be used

(array)

array

Definition

a way of organizing a collection of related data, using a variable name

(type casting)

type casting

Definition

making a one type of variable act like another type of variable for a single operation.

(arithmetic)

arithmetic

Definition

(+)(-)(*)(/)(%)

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

cprog Objective

cprog Objective

Upon completion of this course, students will be able to:

-write and compile code that utilizes programming constructs -use pointers and variables to discover the indirect properties of data storage -comprehend the basics of memory management, data representation and storage -identify and label various data types as scalar vs. composite -distinguish and explain difference between homogeneous and heterogeneous composite data types -break down and separate code into functions and illustrate the use of parameter passing -justify the use of various programming constructs within code solutions -discover the standard libraries and use libraries in solving problems

Definition

students should be able to -Write programs -use pointers effectively -understand what memory management is. -use the different data types -use the different libraries to do what your trying to do

Method

I will be measuring my success in this class on whether or not i will be able to complete the projects.

Measurement

According to my method, i am understanding the basics of what i need to do, but when it comes to putting it all together in a programs by my self, i am only able to do about have of it. I end up needing to get assistance from Matt or class mates.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • i am doing pretty good
  • there is definitively room for improvement
  • i think my method is a pretty good way to measure success

Experiments

Experiment 1

Question

What would happen if i left the \n off of a printf statement?

Resources

According to resources on wikipedia, \n is used to space lines when a program is being run.

Hypothesis

I think that if i leave the \n off of a printf, that the result will look cluttered and will join lines together.

Experiment

I am going to test this experiment by writing a simple “hello world” program and leave the \n off of it

Data

When i take the \n off of “Hello World!\n” the command prompt is jammed right after Hello World!

Analysis

Based on the data collected:

  • Was your hypothesis correct? yes my hypothesis is correct

Conclusions

I conclude that if you want organized program and want to be able to easily read your stdout statements you need to properly place \n to break up your lines.

Experiment 2

Question

What will happen if i remove the return(0); from a simple Hello, world program?

Resources

According to people on wikipedia, unless you declare something to be void, then you have to return something.

Hypothesis

I think that if i take the return(0); off of the Hello World program that if will either not compile or that it will seg fault.

Experiment

I am going to erase the return(0); from the Hello World program and attempt to compile it.

Data

When i erase the return(0); from the program and compile it, it does not seg fault, it compiles fine, and runs fine.

Analysis

Based on the data collected:

  • Was your hypothesis correct? No, my hypothesis was not correct

Conclusions

I have concluded that in my Hello World program, that not having a return statement does not affect it, i am assuming that is because all the program is doing it printing a statement, it is not dealing with any functions that would have values. (sound like Another Experiment?)

Experiment 3

Question

What would happen if i erased the header file <stdio.h> from the Hello World program

Resources

I have been reading on Wikipedia, that stdio.h includes the input and output functions for c programming.

Hypothesis

I think that if i take off the stdio.h header file from the Hello World program, that it will not compile, and tell me that it does not know what printf function is.

Experiment

To test this Experiment i am going to remove the stdio.h header file and compile the remainder of the code.

Data

When i removed the header file stdio.h the compiler gave me a warning that said “ warning: incompatible implicit declaration of built-in function 'printf'” but the program still ran correctly.

Analysis

Based on the data collected:

  • Was your hypothesis correct? My hypothesis was for the most part correct

Conclusions

I have concluded that depending on what functions you want to use in your programming you need to include the proper header files.

Part 2

Entries

Entry 5: 3/6/2012

Today in C/C++ we started to look at stuff in C++ for the first time. I learned that C++ is backwards compatible with C. I also learned that C++ is a object oriented programming language, and can be more easily managed.

  • C++ is backwards compatible with C.
  • all the programs i have written in C can be compiled and run with C++

Entry 6: 3/8/2012

Today in C/C++ we took a look more at C++, i learned that you save your files with .cc rather than .c. Also i learned that you compile your code with G++ rather than with gcc.

  • compile with G++, save code with .cc
  • if your code isnt saved in the right format it wont compile with the right compiler.
  • public, privite

Entry 7: 3/13/2012

Today in C/C++ we looked more at concept in C++, we spent some more time with public and private concepts. I learned that you can access things that are private by using a var that is public that can access the private vars.

  • public and private
  • you cant access vars that are put in private if you are outside of the boundaries.
  • public and private

Entry 8: 3/15/2012

We have been looking more at C++ code, and we have been learning some concepts such as inheritance. I have learned that child classes can inherit things from parent classes

  • inheritance
  • its important to understand the relationship between the classes

Keywords

cprog Keywords

(compiler)

compiler

Definition

a computer program that takes a file written in source code and changes it into a different computer language to run the program.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

gcc -o file file.c

(Preprocessor)

Preprocessor

Definition

a program that processes source code before its gets compiled.

Demonstration

(Assembler)

Assembler

Definition

a program that changes assembly language into computer language.

(Return Types)

Return Types

Definition

a function that needs to be put at the end of a method, that tells the computer what to return.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

#include <stdio.h>
 
int main()
{
    return(0);
}

(inheritance)

inheritance

Definition

a way to re-use code, from higher up classes

(public class)

public class

Definition

a class in C++ programming that all entities can access.

(private class)

private class

Definition

a class in C++ programming that only variable in defined in the private class can access, unless a pointer is used.

(multi-file program)

multi-file program

Definition

a program that is broke up into multiple header and .cc files, that are all brought together in main.cc

cprog Objective

cprog Objective

-write and compile code that utilizes programming constructs -use pointers and variables to discover the indirect properties of data storage -comprehend the basics of memory management, data representation and storage -identify and label various data types as scalar vs. composite -distinguish and explain difference between homogeneous and heterogeneous composite data types -break down and separate code into functions and illustrate the use of parameter passing -justify the use of various programming constructs within code solutions -discover the standard libraries and use libraries in solving problems

Definition

students should be able to -Write programs -use pointers effectively -understand what memory management is. -use the different data types -use the different libraries to do what your trying to do

Method

I will be measuring my success in this class on whether or not i will be able to complete the projects.

Measurement

According to my method, i am understanding the basics of what i need to do, but when it comes to putting it all together in a programs by my self, i am only able to do about have of it. I end up needing to get assistance from Matt or class mates.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • i am doing pretty good
  • there is definitively room for improvement
  • i think my method is a pretty good way to measure success

Experiments

Experiment 4

Question

What would happen if i changed the “” around the printf statement in the Hello World program to ''?

Resources

From some resources on Wikipedia, if i were to run the program with single quotes instead of double quotes it would segfault

Hypothesis

I think that the program will have some warnings compiling the code (do not know what problems in specific) and will have a segmentation fault when i go to run it.

Experiment

To test this i am going to replace printf(“Hello, World!\n”) with printf('Hello, World!\n'). compile and run

Data

When i change out the quotations, the compiler says “ warning: character constant too long for its type hello.c: In function 'main': hello.c:3: warning: passing argument 1 of 'printf' makes pointer from integer without a cast /usr/include/stdio.h:339: note: expected 'const char * restrict' but argument is of type 'int'”. And then it seg faults when i run it.

Analysis

Based on the data collected:

  • Was your hypothesis correct? Yes it was
  • Is there more going on than you originally thought? yes

Conclusions

I have concluded that one little syntax error can totally change what the program thinks you want to do.

Experiment 5

Question

Can i use both printf and cout statements within the same code?

Resources

c++ pocket reference

Hypothesis

Based on what i have been reading in the C++ pocket reference, most c code can be used in a c++ program, compiled with G++. My hypothesis is that i can use both printf and cout statements in the same code provide it is compiled as C++.

Experiment

I am going to write a program in C++ and compile it in C++ and use both a printf and cout statement.

Data

The program compiled fine and ran fine with mixing both printf and cout statements.

Analysis

Based on the data collected:

  • Was your hypothesis correct? yes my hypothesis was correct

Conclusions

I can conclude that C++ is backwards compatible with C provided u include the correct header files.

Retest 2

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).

Part 3

Entries

Entry 9: 4/3/2012

we have been doing some multi- file program examples in class. Doing multi file programs keep your code more organized. It takes longer and uses more over head to use muli-file programs.

  • multi-file program
  • more organized code

Entry 10: 4/5/2012

In class we have been learning about multi-file programs, and in order to do that you need to create .o files. I learned you have to make a .h file w/ a corresponding .cc file, in order to get a .o file. then include that header file in your program using “” instead of <>

  • .o files
  • need them for making multi-file programs

Entry 11: 4/24/12

Today in C/C++ class we learned a little more about classes. We talked about the “friends” class. I learned that kids cannot access their parents private parts, but friends can access their parents private parts.

  • friends classes
  • friends can have access to the private things in the parent class

Entry 12: 4/26/12

today in C/C++ class Matt reviewed a little bit about forms. Forms cannot be used for every thing, but if you are in a situation where a form could be used it will save a lot of time, and code.

  • forms
  • can save you a lot of time and hassle

cprog Keywords

(protected)

protected class

Definition

protected base class can be accessed by a friend or member of any class by using a pointer to reference it.

(Friend)

friends class

Definition

can declare an external function as friend class to get access to the private and protected parts of the class

(polymorphism)

polymorphism

Definition

polymorphism is making a variable, objects, or function have more than one form.

(File Access)

File Access

Definition

accessing a file out side of the program to use by, and either reading, writing, or appending that file. to read you put “r” to write you put “w”

(Command line arguments)

command line arguments

Definition

an argument sent to a program being called. usually you type in the command prompt the name of the program followed by you command line argument like a file.

Demonstration

Demonstration of the chosen keyword.

lab46:~$ ./test file.csv
(cin)

cin

Definition

in C++ found in the header file iostream, overloads the left bit-shifter operator. usually takes info from user through keyboard. syntax is »

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <iostream>
 
int main()
{
   cin>>x>>y:
    return(0);
}
(cout)

cout

Definition

in C++ found in the header file iostream, overloads the right bit-shifter operator. standard out put is usually the screen. syntax is «

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <iostream>
 
int main()
{
   cout<<"this is going to the screen"<<"\n";
    return(0);
}
(cerr)

cerr

Definition

in C++ found in the header file iostream. The error output, normally the screen. syntax is «

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <iostream>
 
int main()
{
   cerr << "Error message : " << str << endl;
    return(0);
}

cprog Objective

cprog Objective

-write and compile code that utilizes programming constructs -use pointers and variables to discover the indirect properties of data storage -comprehend the basics of memory management, data representation and storage -identify and label various data types as scalar vs. composite -distinguish and explain difference between homogeneous and heterogeneous composite data types -break down and separate code into functions and illustrate the use of parameter passing -justify the use of various programming constructs within code solutions -discover the standard libraries and use libraries in solving problems

Definition

students should be able to -Write programs -use pointers effectively -understand what memory management is. -use the different data types -use the different libraries to do what your trying to do

Method

I will be measuring my success in this class on whether or not i will be able to complete the projects.

Measurement

According to my method, i am understanding the basics of what i need to do, but when it comes to putting it all together in a programs by my self, i am only able to do about have of it. I end up needing to get assistance from Matt or class mates.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

i am doing pretty good there is definitively room for improvement i think my method is a pretty good way to measure success

Experiments

Experiment 7

Question

What happens if i leave the semi colon off of the end of a printf statement

Resources

C pocket reference

Hypothesis

Based on what i have been reading in the C pocket reference, if i leave a needed semi colon off of a printf statement it will give me a syntax error and not compile.

Experiment

I am going to take the semi colon off of the Hello, world! program's printf.

Data

When i took the semi colon off of the Hello, World! program and tried to compile it, the following error occurred: hello.c: In function 'main': hello.c:4: error: expected ';' before 'return'

Analysis

Based on the data collected:

  • Was your hypothesis correct? Yes my Hypothesis was correct

Conclusions

I can conclude that if you have even one syntax error it will not compile your code, but it is very helpful by telling you where it is ( even down to telling you what line in the code it is on)

Experiment 8

Question

What will a simple for loop do if i change i++ to i–?

Resources

C programming text book

Hypothesis

Based on what i have read in the C book i++ increments by 1 every time it loops, my hypothesis is that i– will decrement by 1 every time it loops.

Experiment

#include<stdio.h>
 
	int main()
	{
     		int i;
     		for (i = 0; i < 10; i--)
     		{
          		printf ("i=%d\n",i);
 
     		}
     	return 0;
	}

Data

When i ran this program with i– in the for loop, it did decrement by 1 but it continuously looped, and i had to exit the terminal.

Analysis

Based on the data collected:

  • Was your hypothesis correct? Sort of, it did decrement.
  • What shortcomings might there be in your experiment? yes, i did not change the counter sign in the for loop to account for decrementing.

Conclusions

I have concluded that you can increment and decrement in a for loop, just make sure you change the counter statement.

Retest 3

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).