User Tools

Site Tools


opus:fall2012:dmckinn2:part1

Part 1

Entries

Entry 1: 9/5/2012

Today we cloned our own personal repository on lab46. A repository is great for creating programs because it gives you version control. Version control allows you to save a version of your file every time you make a change, and allows you to go back and see previous versions.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • version control
  • Why was this significant? you can save a version of your file every time you make a change and have it organized.

Entry 2: 9/11/2012

Today we cloned a copy of the “bignum” repository. The bignum repository has a bunch of files and utilities that we can use to help us with our own bignum project.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • bignum repository
  • has very helpful tools to use for creating our bignum programs

Entry 3: 9/18/2012

Today in discrete Matt showed us his “gimmeh” script that he wrote. It was very nifty, it allows us to enter some of our contact info, and also certian things about the class(s) that i am taking with Matt. The first thing is to tell him if the keywords that where assigned to you where discribed good enough to give a dipslay.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • the “gimmeh” script
  • it will help us know what is due and when. And it will also help matt for collecting data.

Entry 4: 9/25/12

Today in class, Matt showed us a little bit about sets. We learned the notation that you use. We also learned about subsets. Matt had us start to write a program asking the user for some input and then putting then into a set and show the output in set form.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • Sets
  • not sure yet, we just started to talk about them(seems to me like they are kinda like arrays)

Keywords

data Keyword 1

dynamic memory allocation (malloc/free)

Definition

dynamic memory allocation is the task of allocating a free chunk of memory specific to the size you predetermine in bytes, by using the malloc function. The chunk of memory is not always in the same location hence being “dynamic” instead of static. By using the “free” function, that will release the block of memory back to the system.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • wikipedia
  • class
  • Reference 3

data Keyword 1 Phase 2

passing by address (function parameter passing)

Definition

Passing by address is just one of the ways that you pass a variable into a function. This is done not by passing the variable itself, but by passing the variable address. The only uses for this type of variable passing that I have encountered are arrays.

References

Demonstration

Demonstration of the indicated 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>
void tripnum(int *x)
{
*x = (*x) * (*x) * (*x);
}
 
int main ( )
{
int num = 10;
tripnum(&num);
printf(" Value of num is %d\n”, num); // Value of num is 1000
return (0);
}

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

lab46:~/src$ gcc -otripnum tripnum.c
lab46:~/src$ ./tripnum
 Value of num is 1000 

discrete Keyword 1

left projection

Definition

Left Projection, in programming logic always returns the left-side value in a Truth table. So for values P and Q in a truth table, the left projection always reflects the value of P.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • wikipedia
  • class
  • Reference 3

discrete Keyword 1 Phase 2

Left Complementation

Definition

Left Complement is similar to negation p. it is a logic operation that basically negates the p. For example if p was a 1 it would not matter what q was the result would be a 0. Likewise if p was a 0 regardless of q the result would be a 1.

References

Demonstration

Demonstration of the indicated 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>
#include<stdlib.h>
char lproj(char, char);
char p;
char q;
int main()
{
 printf("P | Q | X | \n");
 printf("----------- \n");
 p = 0;
 q = 0;
 printf("%d | %d | %d\n",p,q,lproj(p,q));
 p = 0;
 q = 1;
 printf("%d | %d | %d\n",p,q,lproj(p,q));
 p = 1;
 q = 0;
 printf("%d | %d | %d\n",p,q,lproj(p,q));
 p = 1;
 q = 1;
 printf("%d | %d | %d\n",p,q,lproj(p,q));
 printf("enter either 1 or 0 for P\n");
 printf(":");
 scanf("%d", &p);
 printf("enter either 1 or 0 for Q\n");
 printf(":");
 scanf("%d", &q);
 printf("%d | %d | %d\n",p,q,lproj(p,q));
 return(0);
}
char lproj(char p, char q)
{
char x;
if(p==1)
{
    x=0;
}
if(p==0)
{
    x=1;
}
return(x);
}

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

lab46:~/src/discrete$ ./ttable
P | Q | X |
-----------
0 | 0 | 1
0 | 1 | 1
1 | 0 | 0
1 | 1 | 0
enter either 1 or 0 for P
:0
enter either 1 or 0 for Q
:1
0 | 1 | 1

Experiment 1

Question

If you take the brackets off of an if statement will it still compile and run?

Resources

based on some wikipedia articles, there are many ways to write if statement and if else statements.

Hypothesis

Based of what i know about c programming, and what i have read on wikipedia, i think that the program will still run with brackets on the if statement. I also think when you try to compile the program it will yell at you and give some warnings.

State your rationale.

Experiment

I am going to write a program with some sort of if statement in it and try to compile and run the program with the brackets on and then with them off.

Data

The data that i have collected from doing this experiment confirms that the program will compile and run with the brackets taken off of the if statement and also with the brackets on the if statement.

Analysis

Based on the data collected:

  • My hypothesis was partially correct.
  • Is there more going on than you originally thought? It will compile with no issues
  • What shortcomings might there be in your experiment?
  • What shortcomings might there be in your data?

Conclusions

My conclusion is that functions can be written different ways. At first i did not think that an if statement would run without brackets, but then after some research on wikipedia, i thought a program will probably run, i just didnt think it would compile cleanly. After preforming the experiment i found that not only will the program run with or with out brackets but the compiler runs fine and does not give any warnings or errors.

opus/fall2012/dmckinn2/part1.txt · Last modified: 2012/09/30 17:24 by dmckinn2