Table of Contents

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.

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.

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.

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.

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:

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:

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:

Conclusions

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