User Tools

Site Tools


haas:spring2014:cprog:projects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:spring2014:cprog:projects [2014/02/24 14:23] – [Week 5] wedgehaas:spring2014:cprog:projects [2014/04/18 14:56] (current) – [Projects] wedge
Line 13: Line 13:
   * [[/haas/spring2014/cprog/projects/nikhilam|Nikhilam]] (due 20140228)   * [[/haas/spring2014/cprog/projects/nikhilam|Nikhilam]] (due 20140228)
   * [[/haas/spring2014/cprog/projects/multby11|Multiply by 11]] (due 20140307)   * [[/haas/spring2014/cprog/projects/multby11|Multiply by 11]] (due 20140307)
-  * [[/haas/spring2014/cprog/projects/vertcross|Vertically and Crosswise]] (due 20140314)+  * [[/haas/spring2014/cprog/projects/vertcross|Vertically and Crosswise]] (due 20140321) 
 + 
 +======Week 10====== 
 + 
 +  * Questions 
 +  * structs 
 +  * structs in action 
 + 
 +======Week 9===== 
 +  * Question and answer week. Some good code examples too. 
 + 
 +======Week 8===== 
 +  * As I teach the lab, I wasn't able to give out warning grades. I sent a list to Joe, who promptly did not get to submitting warning grades. However... I was rather unsettled by what I saw: 
 +    * 16 total people in the class 
 +    * 7 are doing fine (~43%) 
 +      * most have only submitted 3 or 4 out of 6 projects 
 +      * most have been very attentive on their Opus 
 +      * most have attended most if not all classes 
 +    * 2 would be doing fine (~12%) if they would keep their Opus up-to-date (at least one entry per week) 
 +      * projects/attendance are actually on the upper end 
 +      * don't forget about the Opus! 
 +    * 7 are not doing fine (~43%) 
 +      * none to 2 out of 6 projects submitted 
 +      * attendance is all over the place (never through all) 
 +      * opus is all over the place (1 entry total through just over 1 entry per week) 
 +    * So, 2+7 = 9; 9/16 = 56%. 
 +      * more than half the class is not passing (this is new to me) 
 +        * I don't seem to be getting enough questions based on the lack of work I'm seeing 
 +        * I know some people aren't spending enough time on class material (how are you going to learn it if you don't play with it) 
 +      * 56% of the class would get an F in the class if grades were to be submitted now 
 +  * We seem to have gotten about a week behind on project completion. Well, for those who have been being active and attentive in class. 
 +    * I've made the next project due in 2 weeks instead of 1 to help you get caught up. 
 +  * Remember: 
 +    * I can answer questions from Joe's side of class 
 +    * Joe can answer questions from my side of class 
 +    * We have tutors, they can help 
 +    * I can answers questions from my side of class 
 +      * I can answer said questions outside of class 
 +      * I can answer said questions inside of/during class 
 +        * Asking questions is good 
 +======Week 7====== 
 + 
 +  * Be sure your Opus is up to date with your weekly progress and exploits! 
 +  * loops 
 +    * for 
 +    * while 
 +    * do while 
 +  * functions 
 +    * return type 
 +    * parameters 
 +    * function prototypes
 ======Week 6====== ======Week 6======
  
Line 22: Line 72:
     * while     * while
     * do while     * do while
 +  * Type in these programs, compile/execute them, and pour through the code. Your task is to:
 +    * figure out what is going on with each and every step
 +    * ask questions on things you do not understand
 +  * Be sure to update your Opus!
 +
 +=====Single Dimensional Array of Characters=====
 +Arrays are commonly used to simulate strings in C.
 +
 +<code c 1>
 +/*
 + * This code should produce a warning on compilation. Fix it.
 + */
 +#include <stdio.h>
 +
 +int main()
 +{
 +    int i;
 +    char input[12];
 +
 +    fprintf(stdout, "Enter an 11-character max string: ");
 +    fgets(input, 11, stdin);
 +
 +    fprintf(stdout, "There are %d characters in your string\n", strlen(input)+1);
 +
 +    for(i=0; i<=strlen(input); i++)
 +    {   
 +        if (input[i] == '\n')
 +            fprintf(stdout, "input[%d]: '\\n' (%3.3hhu, 0x%.2hhX)\n", i, *(input+i), *(input+i));                                                                                   
 +        else if (*(input+i) == '\0')
 +            fprintf(stdout, "input[%d]: '\\0' (%3.3hhu, 0x%.2hhX)\n", i, *(input+i), *(input+i));
 +        else
 +            fprintf(stdout, "input[%d]: '%c'  (%3.3hhu, 0x%.2hhX)\n", i, *(input+i), *(input+i), *(input+i));
 +    }   
 +    return(0);
 +}
 +</code>
 +=====Single Dimensional Array and Memory=====
 +To have a better understanding of arrays, we should note how they are represented in memory. Pay close attention to the output of this program:
 +
 +<code c 1>
 +#include <stdio.h>
 +
 +int main()
 +{
 +    int i;
 +    unsigned short int data[8] = { 255, 256, 49152, 13, 65535, 2600 };
 +
 +    fprintf(stdout, "=======================================================\n");
 +    fprintf(stdout, "Please enter a valid unsigned short int value: ");
 +    fscanf(stdin, "%hu", &data[6]);
 +
 +    fprintf(stdout, "Please enter another valid unsigned short int value: ");
 +    fscanf(stdin, "%hu", (data+7));
 +
 +    fprintf(stdout, "The data array starts at address 0x%X\n\n", &data);
 +    for(i = 0; i < 8; i++)
 +    {   
 +        fprintf(stdout, "*(data+%d) contains: %hu (0x%.4X)\n", i, *(data+i), *(data+i));
 +        fprintf(stdout, " (data+%d) is at address: 0x%X\n", i, (data+i));
 +        fprintf(stdout,    Lower-Order byte at 0x%X contains: 0x%.2hhX\n", ((char *)data+(i*2)+0), *((char *)data+(i*2)+0));
 +        fprintf(stdout,    Upper-Order byte at 0x%X contains: 0x%.2hhX\n", ((char *)data+(i*2)+1), *((char *)data+(i*2)+1));
 +        fprintf(stdout, "\n");                                                            
 +    }
 +    fprintf(stdout, "=======================================================\n");
 +
 +    return(0);
 +}
 +</code>
 +
 +=====Command-line Arguments and 2D Array Manipulation=====
 +Here we play with a two-dimensional array created by the system, via the command-line arguments provided to main():
 +
 +<code c 1>
 +/*
 + * Fun with arrays and loops using command-line arguments
 + *
 + * Try renaming the executable, and running it with different numbers/lengths of arguments
 + */
 +#include <stdio.h>
 +#include <string.h>
 +
 +int main(int argc, char **argv)
 +{
 +    int i, j;
 +
 +    fprintf(stdout, "You typed: ");
 +    for(i = 0; i < argc; i++)
 +        fprintf(stdout, "%s ", argv[i]);
 +    fprintf(stdout, "\n\n");
 +
 +    for(i = 0; i < argc; i++)
 +        fprintf(stdout, "*(argv+%d) / argv[%d]: %s\n", i, i, argv[i]);
 +    fprintf(stdout, "\n\n");
 +                                                                                          
 +    for(i = 0; i < argc; i++)
 +    {   
 +        for(j = 0; j <= strlen(argv[i]); j++)
 +        {   
 +            if ((*(*(argv+i)+j)) == '\0')
 +                fprintf(stdout, "*(*(argv+%d)+%d): '\\0' ", i, j); 
 +            else
 +                fprintf(stdout, "*(*(argv+%d)+%d): '%.2c'  ", i, j, (*(*(argv+i)+j)));
 +
 +            fprintf(stdout, "(%.3d / 0x%2.2X)\n", (*(*(argv+i)+j)), (*(*(argv+i)+j)));
 +        }   
 +        fprintf(stdout, "\n");
 +    }   
 +    fprintf(stdout, "\n");
  
 +    return(0);
 +}
 +</code>
 ======Week 5====== ======Week 5======
  
haas/spring2014/cprog/projects.1393251805.txt.gz · Last modified: 2014/02/24 14:23 by wedge