User Tools

Site Tools


opus:fall2011:jdavis34:part1

Part 1

Entries

September 21, 2011

I was a bit unsure of a few things that we were doing, so this is a bit late. With the emails that we have received via alpine I am a bit more clear where we stand. So I am a quite late on actually getting to the first of my dated Opus entries, though I enjoy more being inside the “lair” or email, its probably a good thing I begin this documentation part of the class.

I picked up a few good things I am sure I will be making use of throughout this semester,

  1. Creating files within the directory I plan to use them Via Nano.
  2. compile them with gcc:
  gcc -o programname sourcecode.c 
- Then run them:
  ./programname 
  
  Where sourcecode.c = the actual file created with Nano
  
  programname = the name of the program created when the file is compiled.
  

Lastly to finish this entry, I am not quite sure if there is a data base for where we are suppose to be getting Keywords from or if they are just picked up as we go.

I plan to begin working on making a Number conversion from Decimal to Hex for one of my beginning projects.

September 23, 2011

So I spent a good amount of time last night, because once again awesome folks at xda have a bit on dx2, working on flashing different roms to my phone. Though I wound up restoring the Nand back-up I had to make there was a few decent roms which show a promising future.

-moto blur taken out

-bloatware removed

-Root access (not the roms doing)

The bootstrap for this phone (Droid x2) has yet to be as solid as the other ones.

-can only gain access to it via running it through the apk on the phone. -It is wiped with data if on the ROM install.

  1. Not a issue because most ROMs flashed to the device have it built in. But if for any reason you get errors or soft brick it, not as easy as previous versions to deal with.
  2. Semi-periminant down sides are of those above.

The Rom I played with, though I did not spend too much time with it was that of eclipse .6 remix. The problem I did not like is you have to currently wipe data when installing so contacts and all are a pain process to port back onto the phone. The Facebook contacts sync isn't active, but should be released in .7. There is a face book app I read about to help sync it but just not as solid of a built ROM, hoping cyanogen will have his work released soon for the Droid x2.

September 27, 2011

Today I spent a few hours reading into some beginner tutorials on C/C++. Made a few stupid programs that do pretty much nothing, but helped me start to get a better understanding of how things work, and how to write a little.

Made one with a age input, favorite day input and plan to do a few more once I am done with this if I have time later after I get other homework done. All in all slightly accomplishing day considering was one of the very few people who successfully got our windows 7 unattend.xml to properly work.

September 30, 2011

Well today I was kinda excited after class because I picked up a HP touch pad. I spent most of my night distracted by it, creating a partition for ubuntu and getting it installed. Unfortunetly my work with it was cut short with a call from family, our grandmother on moms side just passed, exactly 3 months from the passing from our mom. As most of you can guess alot of my time has been with family and trying to keep positive about all of this.

Topics

Variables

Are allocated blocks of storage in memory that we can associate with a name, such as “pirce”, “age”, “year”, etc.

Name Type Range

int Numeric - Integer -32 768 to 32 767

short Numeric - Integer -32 768 to 32 767

long Numeric - Integer -2 147 483 648 to 2 147 483 647

float Numeric - Real 1.2 X 10-38 to 3.4 X 1038

double Numeric - Real 2.2 X 10-308 to 1.8 X 10308

char Character All ASCII characters

Examples of variables can be but not limited to:

int x %d
short x %d
long x %d
char x %c
float x %f
double x %lf

Sizeof

The sizeof operator gets the size of its operand.

This initializes X to the size of c, resulting in a integer of the type size_t:

size_t X = sizeof(c);

Standard I/O (STDIO, STDOUT, STDERR)

The preferred method of performing input and out. The three I/O connections are called standard input (stdin), standard output (stdout) and standard error (stderr). -Standard input is data (often text) going into a program. -Standard output is the stream where a program writes its output data. -Standard error is another output stream typically used by programs to output error messages or diagnostics.

#include <stdio.h>
printf()
scanf()

Header file

A header file is a file containing C declarations and macro definitions to be shared between several source files. You request the use of a header file in your program by including it, with the C preprocessing directive `#include'.

example:

#include header.h
#include <stdio.h>
#include <math.h>

arithmetic (equations, operators)

Binary arithmetic operators are +, -, *, /, and %.

         int a = 25;
         int b = 5;
         int c;
 
         c = a + b;
         printf( "a + b = %dn", c );
 
         c = a - b;
         printf( "a - b = %dn", c );
 
 
         printf( "a * b = %dn", a * b );
 
         c = a / b;
         printf( "a / b = %dn", c );
 
         c = 100 % 3;
         printf( "a % b = %dn", c );

logic and operators

and && groups left to right, returns 1 on unequal comparison, and 0 anything else. or || groups left to right, returns 1 if if either of its operands compare unequal to zero, and 0 otherwise.

“String”

In computing, a C string is a character sequence terminated with a null character

In the following, the string literal “hello world” is printed.

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
 
printf("hello world");
}

Repetition/Iteration Structures For

The variable initialization allows you to either declare a variable and give it a value or give a value to an already existing variable. Second, the condition tells the program that while the conditional expression is true the loop should continue to repeat itself.

FOR - for loops are the most useful type. The syntax for a for loop is

for ( variable initialization; condition; variable update ) {
  Code to execute while the condition is true
}

Repetition/Iteration Structures While

while loop is like a stripped-down version of a for loop– it has no initialization or update section. However, an empty condition is not legal for a while loop as it is with a for loop.

while ( condition ) { Code to execute while the condition is true }

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

Arrays

allow the programmer to store more than one value in a variable. An array is the equivalent of a box divided into partitions, each containing a piece of data. so this means an array is- An array is a series of elements of the same type placed in memory locations that can be individually referenced by adding an index to a identifier.

type name [elements];

int array [5] = { 0, 1, 2, 3, 4 };

this initializes the array to 5 place holders

accessing array elements

array[0]; //value of '0'
array[1]; //value of '1'
array[2]; //value of '2' 

Trying to access a value outside the bounds of index 1 through size_of_array – 1, results in runtime errors. Your compiler will not complain, but your program will crash when it executes.

Multi-dimensional arrays

multi-dimensional arrays are arrays of arrays.

#define WIDTH 2
#define HEIGHT 5
 
int multiarray [HEIGHT][WIDTH];
int n,m;

this initializes the multi-dimensional array to 2 dimensions of a 5 element array

File Access (Read, Write, Append)

To open a file you need to use the fopen function, which returns a FILE pointer. Once you've opened a file, you can use the FILE pointer to let the compiler perform input and output functions on the file.

you first need a pointer such as

FILE *fp;

You then need to use this pointer and point to the file and what you intend to do with it

 FILE *fp;
fp=fopen("c:\\test.txt", "r");

r - open for reading

w - open for writing (file need not exist)

a - open for appending (file need not exist)

Objectives

demonstrate structured and object-oriented problem solving concepts

By the end of this semester show the ability to demonstrate the use of logic and structure in program writing.

Method

The method of this could be variously described, but a easy effective means would be to ask a student to create a set of instructions that:

1. creates a program

2. Initializes the program

3. contains a logical sense to obtain a desired result, IE: if someone wanted to multiply 2 numbers and get a result.

Measurement

To asses how a students effectiveness was in creating this first:

1. Does the program compile without errors.

2. Does the program ask for input for the 2 variables to be multiplied.

3. Does the program give the correct desired answer for this function it is to serve.

4. Lastly the code in which it is written, was it initialized properly, does it only prompt the user for one occurring event, Does it ask the user to input a variable to end, does it continuously loop and not close itself without the user having to exit the program, there is a large list in structuring the means to a achieved goal and many ways to reach it, but in the end was it the most efficient.

Analysis

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

  • How did you do? So far have created a few usable logical programs, simple but usable.
  • Room for improvement? ALOT
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

Experiments

Experiment 2

Question

What is the use of \n and to what effect does it have if in a simple program designed to print “hello world” if:

1. it exists.

2. it does not.

Resources

created a simple program that says “hello world”

1.

#include <stdio.h>
 
void main()
{
  if(printf("Hello World\n"))
}

2.

#include <stdio.h>
 
void main()
{
  if(printf("Hello World"))
}

Hypothesis

Based on what I know the function of /n is, to tell the program next line, I think it either will not compile, or it will not display “hello world” on its own line creating a new line after execution. State your rationale.

Experiment

As listed in resources I created 2 programs to test one with one without, and plan to run both and record the results.

Data

1.

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

2.

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

Analysis

Based on the data collected:

  • was your hypothesis correct? Yes and no, I was not sure if it would compile and it did, but as I suspected if it did, it would print the text without breaking to a new line.
  • was your hypothesis not applicable? yes
  • is there more going on than you originally thought? Not really due to this test was kinda simple, in understanding context of code and its importance to output.

Conclusions

Based on the data collected, It is obvious the use, and results of having /n in program syntax, where as if it does not exist what will happen.

Experiment 3

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

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.

Hypothesis

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.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • was your hypothesis correct?
  • was your hypothesis not applicable?
  • is there more going on than you originally thought? (shortcomings in hypothesis)
  • what shortcomings might there be in your experiment?
  • what shortcomings might there be in your data?

Conclusions

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.

opus/fall2011/jdavis34/part1.txt · Last modified: 2012/03/01 13:35 by jdavis34