Thursday, December 13, 2012

Multiple Functions and Boolean Logic



Wow, that was an extremely long lesson.  I start out by doing two lesson a night.  Now, with all the notes, code writing and code testing, my reeducation time slot is getting wider and wider.  

Well I had 8 lesson to do and here they are:
12.1 Intro GOTO and loops in C.
12.2 About Blocks of Code
12.3 Intro Loops
12.4 Intro to customer functions
12.5 Intro Boolean
12.6 Intro Bit masking
12.7 Using bit masking to change data
12.8 Intro Date Strategies'

I wrote out the code below  and it's pretty interesting that I can get the computer to inform em if the character is Uppercase or Lowercase.  Take a look at the code below.

#include <stdio.h>

int main (void){
  char my_character = 'a';
 
  if ((my_character & 0x20 ) == 0){
  printf("This is upper-case\n");
  }

  if ((my_character & 0x20 ) == 0x20 ) {
  printf("This is lower-case\n");
  }

  return 0;
 }

Codepad.org is not a huge fan of binary.  That or I'm doing something incorrectly.  The obviously answer to resolve this conflict.  Result = I'm doing something wrong.  :-)  Anyways, when I switch to Hexadecimal , my program was running perfectly.

This is extremely interesting to me and I'm beginning to mentally combine the principles I've learn to possibly see the application in which they can be used.  Even this simple program with the two functions using Boolean Logic; by changing one character, the program is able to inform the user if the character is Upper-case or Lower-case.

I love it.  This is beginning to appear that the applications of programming is 'virtually' limitless.

No comments:

Post a Comment