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:
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:
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:
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:
dynamic memory allocation (malloc/free)
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.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
passing by address (function parameter passing)
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.
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
left projection
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.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Left Complementation
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.
Reference 1: http://en.wikipedia.org/wiki/Negation
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
If you take the brackets off of an if statement will it still compile and run?
based on some wikipedia articles, there are many ways to write if statement and if else statements.
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.
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.
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.
Based on the data collected:
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.