User Tools

Site Tools


Sidebar

projects

haas:spring2014:cprog:projects

This is an old revision of the document!


Corning Community College

CSCS1320 C/C++ Programming

Assignments, Documents, Information, and Projects

Projects

Week 5

  • selection statements
    • if/else if/else
    • switch/case
  • arrays
    • creating
    • using
    • pointers
  • loops
    • for loops for assisting in array manipulation
  • probably will not get to all this stuff
  • overview of next project

Week 4

  • WEATHER happened. People still showed up, and we talked about the data type project for a bit, as well as the squares project, and while we did go over new stuff (if statements), I plan to review if() statements again next week.
  • Data Types, continued
  • reviewed squares project
    • input with scanf()
    • 35^2 = 3*4 25 = 1225
    • use simple math expressions to manipulate your input (115 OPERATION NUMBER = 11)
  • if()/selection statements – let the computer make informed decisions, so long as that decision is true or false.
    • if() statements evaluate a condition. Conditions can be a number, or they can be the result of some relational expression. Operators are:
      • == (is equal to)
      • != (is not equal to)
      • < (is less than)
      • ⇐ (is less than or equal to)
      • > (is greater than)
      • >= (is greater than or equal to)
    • a common mistake is to put a single equal sign (=) in a condition.
      • this doesn't check equality, it sets it, and setting is always true
    • using && and ||, we can have compound if() statements
    • if you use an if(), you can have:
      • at most one if() statement
      • 0 or more else if() statements
      • 0 or 1 else statements
  • Looked briefly at ASCII characters and their numeric representation ('A' is 65, space is 32, 'a' is 97, '0' is 48)
  • showed some more mental math
int number = 0;
 
printf("Enter a number (0-10): ");
scanf("%d", &number);
 
if (number < 0)
{
    printf("Error, value is less than 0!\n");
}
else if (number == 1)
{
    printf("ONE!\n");
}
else if ((number <= 10) && ((number % 2) == 0)) // detect even number (compound if)
{
    printf("Even number of %d\n", number);
}
else if ((number == 3) || (number == 7)) // compound if using OR connective
{
    printf("you entered a %d\n", number);
}
else if ((number > 4) && (number < 10)) // compound if using AND connective
{
    printf("remaining odd number of %d\n", number); // how will this only hit 5 or 9?
}
else
{
    printf("value is greater than 10!\n");
}

Week 3

  • Signed values
    • how to represent
    • how to manually encode
      • one's complement (why is this problematic?)
      • two's complement
        • invert, then add 1
    • what this does to the range
    • impact on resulting quantity
  • discuss next week's project: squares
    • input with scanf()
      • need to pass variables by address
      • formatted text string same as with printf()

Week 2

  • We covered some C programming details relating to the data types project:
    • printf/fprintf
      • STDIN/STDOUT/STDERR
      • format string specifiers
        • %d
        • %u
        • %ld
        • %lu
        • %hd
        • %hu
        • %hhd
        • %hhu
        • %c
        • %s
        • the space allocation/zero padding optional value that can be specified within the format string specifier
    • sizeof() function
      • relatedly:
      • low and high values within a fixed size range
      • roll-over
    • logical operators
    • type casting
  • We also looked at cloning BitBucket repositories onto Lab46

Week 1

  • Welcome! Be sure to:
    • Read over the syllabus
    • Subscribe to the class mailing list
    • Using the tutorial, set up a screen session and get on #csci on irc
  • Get familiar with logging into the pod systems, and once there:
    • opening up a terminal
    • logging that terminal onto Lab46 for class work and attendance
  • Get familiar with how to log onto Lab46, and once on:
    • change to your src/ subdirectory
    • create/edit .c files (such as hello.c), and how to save/exit
    • compile the C program (.c file(s)) into an executable with gcc
    • execute the compiled C program (the executable) by specifying a path: ./program_name
  • Familiarize yourself with your Opus, and once there:
    • customize it (title/subtitle)
    • add an introduction
    • create your first week content
  • Contemplate our first set of programs we're going to write:
haas/spring2014/cprog/projects.1392904249.txt.gz · Last modified: 2014/02/20 13:50 by wedge