8/
A simle C program
/* -------		a comment
   -------		       or
   ------- 		a remark
#include <stdio.h>
int main( )
{ 
     printf("---------\n"); (\n=a new line character)
     printf("---------\n");
     (eturn);
}

*Tools
     -compiles
	~text editor	-enter and modify source code	~text.C
	~preprocessor	-deal w/ #~~
	~compiler	-check & translate source code into intermediate code or object code     ~many files test.obj
	~linker		-combine everything into executable code                                             ~test.exe -.dll
     -MSVC++6.0	-handle C or C++programs
               C an IDE (-Interated Development Environment)

SOFTWARE-$50-$100 ACADEMIC VERSION
-Borland/Turbo -Turbo C++4... -C++6.0-Bloodshed Dev C++-----FREE
-Codewarrior C++...
_____________________________________________________________________________________________________

8/27/03
*Memory & Variables
RAM
-----				-----
|__| 				|__|-ingtdims
|__| >your programs		|__|-data	
|    |      / \
|    |instuctions + data
|----|                     /
      need variables request some memoy to do your work > need some variables
*declaring variables 
	int   x   j
	/           \
variable type   variable name
 -naming rules - must follow 
 	*must begin with a letter or an underscore ( _ )
	*additional characters can letters, digits, or -
	*valid - x, name, x123, (miles_per_gallon)-----------------------------------
	*invalid - 123x, miles per gallon, abc#, miles-per-gallon               |
-naming convention - should follow                                                        |
	*use descriptive name       miles_per_gallon(Check) or MilesPerGallon(*) or milesPerGallon(Check) C++/Java Style   
	*don't start with -                 /
	*use consistent naming style
	*avoid all uppercase - MILES_PER_GALLON

*Basic arithmetic
	-part of C langage
	-add(+), sub( - ),mul( * ), div( / ), mod(%)
	  |_________________|   |___________|
		   |		          |	
	5 - 2 = 3 		5 / 2 = 2	-integer division
	5 * 2 = 10		5.0 / 2.0 = 2.5	-floating-point division	
	5.2 * 2.0=10.4    	5 / 2.0 = 2.5 or 	- "
	5.0 * 2.0 = 10.0		5.0 / 2 = 2.5  	- "
*%-give the remainder			         3	2 1 0
	-integer operation         x|  5 |	|0|0..0|0|1|0|1|
	5 % 2 = 1	            |__ |
	6 % 3 = 0	          y	|  7 |
	5 % 13 = 5 	         	|__ |
     int x, y, z;		          z| 37|
     x = 5;
     y = 7;
     z = x * y + 2;
__________________________________________________________________________________________________________________________
											9/3/03
*selection & interation_____________
     |__>make decision                      |_>repetition loop repeat certain task. while (count < n)
     if (hours > 40)				same task
	formula 2
     else
	formula 1
*Algorithm & Problem Solving
     solution
     -a sequence of steps to follow in order to solve some problem.
     -Problem Solving
	-General
	     1.) Understand			CSCI
	     2.)Plan				Analysis	- requirements/specifications
	     3.)Implant				Design		-algorthm	-pseuclocod flowchart
	     4.)Check				Code							
						Test
*Assignment & Arithmetic
	int x;				  _____
 	int y, z;    			  |____|
assignment operator-x = 5;	          	x|=05=| 4 bytes
LHS 	= 	 RHS;		    	y|=12=| 4 bytes
a variable	expression evaluates	z|=00=|4 bytes
x+7=y;	(x)	to a single value		  |____|
	y = x + 7;
	x = x + 1;
*Arithmetic
     -Basic Arith
	+, -, *, /, %---integer division or floating-point div 5/2=2	5.0/2.0=2.5	5.5/2.0=2.75	4.0/2.0=2.0	5.0/2	5/2.0
     -Advanced Arith 
	-Math Library
	#include <math.h>
	      __3			
	y=\/ x		y=sqrt(x);
	     3
	x=n -x=n*n*n;
		x=pow(n,3)
________________________________________________________________________________________________________________________
																9/8/03
*Control Structures
	flow of the program.
	-Three Types
	     1.) Sequence-defonlt---------------|
	     2.) Selection---------------------------> Structre & programming
	     3.) Repetition/Iteration/loop------|

10	|................|		1.) Sequence-default
	|................|			state 1
	|go to 1000.|			state 2
	|	     |			state 3
	|	     |
500	|................|		2.)Selection - male decision on what to do next
	|................|			if, switch		if ( condition )
	|go to 10    |			syntax x		     state 1
	|	     |			if ( condition )		else		
	|	     |			     state 1    		     state 2
1000	|................|			state 2			state 3
	|................|							
	|go to 500  |

int x;
x = ~;
if ( x < 0 )
     printf("x is negative.\n")'
printf("Done\n"); 
~~~~~~~~~~~~~~~
x = 5;					set x to 5
if ( x < 0 )				if x is negative
     printf("Negative\n.");			     put "negative"
else					else
     printf("Non-negative\n.");		     put "none-negative"
printf("Done\n.");				print "done"

*Repetition/Iteration/loop
     -repeat certain task
     -whole, do/while, for
     -to set up a loop
   	*initialize the loop
	*test for termination
	*data modification
     -two types of loops
	*pra-test loops	-while & for
	*post-test 	-do/while
	    \__> perform task at least once.
print x
*print x n times
	
	printf("x is %d\n",x);
-while loop
	initialze the loop
	while ( condition )
	{
	     perform some task
	     data modificate
	}

/* x & n are defined */			x: 10	n: 5	i: 1 
while ( i < = n )
{
     printf ("x is %d\n",x);
     i = i + 1;
}

i = 1;
do
{
     printf("x is %d\n",x);
     i = i+1;
     while ( i < = n);
print n down to 1
/* n is defined*/
i = n
while (i>0)
{
	printf("%d\n",i);
	i=i-1
}
print("Blastoff\n")

if (x < 0)
   printf(....);
print(....);

*Case stucly-Average Program.
problem stort: write  program to calculate the average of a set of valves.
1.) analysis
values? int or real
...
2.) Design-come up with an algonthm
a. Identify major tasks
	-sturctred or hiercrchy chart
b. Document & Refune each task
	-psudocode or flowchart

-get a set of values\
-sum up all values /
-compete the average
-display the average

-Refine:
    initalize some veriables
    while answer is 'y'
	input one value
	add value to sum
	add 1 to count
	get answer ('y' or 'n')
end whole
caculate average - sum/count
display average

______________________________________________________________________________________________________________________-
																9/10/03
*Basic Data Types 
     1.)int		
     2.)char
     3.)float
     4.)double
1.) int {int x; (type -> storage amount, variable name)} -4 bytes range-2billion to 2 billion
unsigned int y;   printf("The size ofint is %d bytes.\n",sizeof (int));
		printf("X is %d\n",x);		int values [100]
		scanf("%d",&x);

2.)char
     -work with one character			__
     -'a', 'A', '5' not equal to 5, ',', '#', 'b'		|__|
     -'\t',"\n'			                    c1|__|<-- asc2 code of a 01100001	75	25(1a)
     -1 byte					|__|				75	26(2d+1n)
     char c1, c2, c3			        c2	|__|				70	    scanf("%c", & c2);
     c1='a';					|__|	character is a, 97		char (name)[50];
     c1=97				        c3	|__|
     printf("Character is %c\n",C,);
     printf("The ascii code is %d]n,"c,);
float		double
%f		%Lf

get the pay tof 10$
get the hours (scanf)
calculate the wage
print the wage
print appropriate message
_____________________________________________________________________________________________________________________
															9/15/03
*float					double
     -floating-point or real			     -double precision or long float
     -4 bytes					     -8 bytes
     -representation-%f				     -default floating-point -%lf
	__|_____|________			__|_____|________			
sign---->| _|_____|_____|__|		sign---->| _|_____|_____|__|
          31--|         |        0		                      63--|         |        0
	   \         /\0.5,0.25.../
	exponet	    mantissa
IEEE floating-point		             1
  -6 significant digits			3.24 = 0.324 x 10
      -35	      58	  
  -10    to 10

*operators & Precedence
hightes ( )					associativity
						left_to_right	- - x -
+, - (unary operators) +5		-3		right_to_left	x * y / z
*, /, % (binary)					left_to_right
+, - (binary operators) 5+2	7-3		left_to_right

lowest = 					right_to_left x = y = z;

result = -[(x-y)*z}; x-y1st *z 2nd ( ) 3rd - 4th
*& and * operators
(
addressing     derefecing
operator	   	 or indirect operator (*p) &x

int x;
	printf("%d",x);
	printf("%d",&x);

* I/O	instructions
     scanf("------", lost of varibles);
     printf("------",list of varible); <----control string

char	%c
int	%d
float	%f
double	%lf
string	%s

int x,y;
char f,l;
double d;
printf("Good eveng\n");
printf("%d",x);
printf("the value is %d", x);
printf("%d is the value", x);
printf("The values are %d and %d", x, y);
printf("my inital is %c%c",f,l);
printf("value is %d",d); <---mistake
printf("value is %lf",d); <---correct
%5d the value is _ _ _ _ 5
-control the width & # of digits after ((floating-point) 
scanf("%d",&x);
scanf("%d%d",&x&y);
scanf("%c%c",&f&l);

scanf("%lf", &number);
*
*
*
printf("do you want to continue(Y/N)-->");
scanf("%c",&answer);
scanf("%c",&answer);

answer = getchar ( );
answer = getc (stdin);

putc(answer); = printf(%c", answer);