1 / 29

Adv Procedural Programming

Adv Procedural Programming. C Fundamentals. Variables. All variables utilized by a C program must be defined. TypeDef Var Name f loat Var double Var int Var long Var c har Var c har Var [X]. Integers.

sarah
Télécharger la présentation

Adv Procedural Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adv Procedural Programming C Fundamentals

  2. Variables All variables utilized by a C program must be defined. TypeDefVar Name float Var double Var intVar long Var char Var char Var[X]

  3. Integers int defines an integer value or whole number, a value without a decimal point. Values defined as integers are stored in memory using 2 bytes of storage and can hold values from 32,766 to -32,766. The first bit of storage is used to identify the sign of the value.

  4. Integers long identifies an integer value that is stored utilizing 4 bytes of storage. As such it can store 231 to -231(2,147,483, 647 to 2,417,483,648). Again the first bit is utilized to define the sign of the value.

  5. Decimals float is used to define a decimal value that is stored in 4 bytes of memory. The first three bytes are the mantissa the remaining byte stores the exponent. 2.295 = 2.295e101 22.95 = 2.2295e102

  6. Decimals Double is used to define very large decimal values, 1.7e-308 to 1.7e308

  7. Characters char values are actually stores as integers -128 to 127 which represents the ASCII value of the character.

  8. typedef Using this statement you can rename a data type in order to make it easier to use. typedef unsigned char xchar; xchar variable;

  9. printf Not only used to output numbers and character stings but also used to format output. printf(“print this”); Output is formatted using escape sequences, a backslash followed by a character.

  10. printf Commonly used escape sequences. \n – The newline character moves the cursor to the next line. printf(“Print This\n”); \t – The tab sequence inserts a tab between the desired characters. printf(“Print\tThis”);

  11. printf Numbers are formatted using format specifiers. • %d - Format integer as decimal • %f – Format float as decimal • %x – Format integer as a hex value • %5.2f – Format a float as 5 digits with 2 decimal points • %5f – Format as a float with 8 digits and now decimal points.

  12. Arithmetic Operators + - Addition - - Subtraction * - Multiplication / - Division % - Modulus (Remainder of Division operation)

  13. Relational Operators == - Are two values equal to one another < - Greater than <= - Greater Then or Equal to > - Less than >= - Less than or Equal to != Not Equal to

  14. Order of Operations ( ) – Parenthesis, everything inside the parenthesis is completed first ^ - Exponent • - Negation % - Modulus *, / - Multiplication, Division +, - - Addition, Subtraction

  15. Assignment Statements Sum = 0 Sum = VarA + VarB These are both statements that assign a value to the Sum variable

  16. Decision Structures if – then : A single decision structure if the condition is true execute the code, it its false don’t execute the code. if (A == B) printf(“Look What You Did/n”);

  17. Decision Structures if – then – else : A two decision structure if the condition is true execute the code, if it’s not then execute some other code. if (A == B) then printf(“Look What You Did/n”); else printf(“Opps You Did This Instead/n”);

  18. Decision Structures Switch - A structure utilized in place of a nested or chained if-then-else structure to react to several different values of a condition. The major drawback to this structure is its limitation to the use of integers. Switch (Var1) { case 1: printf(“It’s a 1/n”); break; case2: printf(“It’s a 2/n”); break; }

  19. Iteration Iteration is another way of referring to repetition or basically repeating selected instructions. There are two basic types of structures utilized when performing iteration: Determinate – you know exactly how many times you want to repeat the operations. Indeterminate-You repeat the operations until a condition is meet but don’t know how many times specifically.

  20. Determinate Structures Remember these structures are used when you know exactly how many times you want to execute the operations. for(var = initial value, terminating value, increment) for(int X = 0, X < 10, X++) This loop will execute 10 times and then stop

  21. Indeterminate Structures These structures are utilized when you don’t know exactly how many time you want the execute the operations. You also have to include a terminating condition that when meet causes execution to stop. Two basic structures pre-test where the condition is examined prior to execution and post-test where the condition is examined after the loop executes at least once.

  22. Indeterminate Structures Standard Pre-Test structure of a while loop. While the condition is true then execute the statement or statements. while (condition is true) { statements; }

  23. Indeterminate Structures A post-test structure that executes the body of the loop at least once the second repetition dependent on the outcome of the test. do { statements; statements; } while (conditon)

  24. Functions Before being used by a program a function must be declared sand a function prototype must be included in the program. Function name (data type parameter name) return type function name (data type parameter name)

  25. Functions Functions are called using the function name and the arguments or data that is sent to the function. FunctionName (arguments) Functions can appear at the top or the bottom of a program usually the function declaration is place at the top of the program while the function itself is placed at the bottom of the program.

  26. Functions A function is defined by its header which his located at the top of the function and is similar to the function declaration. RtnTypeFunctionName(Arguments) void Function(Value1, value2) --- Header { Function Body }

  27. Program Development • Planning What has to be done, what information is to be delivered to the user. When is it needed, how will it be used, what format does it need to take. • Analysis How is the information currently gathered, does it exist and where does it reside, what format does it take. How is it ordered, what security is needed. What data is needed and what format does it need to be in.

  28. Program Development • Design How will the new system work what procedures and functions will be used what order will the operations take • Implementation The program is actuality developed, tested, debugged and refined

  29. Program Development • Maintenance The program is changed according to business needs and any problems that were missed in testing are corrected

More Related