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.
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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
All variables utilized by a C program must be defined.
float Var double Var
intVar long Var
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.
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.
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
Double is used to define very large decimal values, 1.7e-308 to 1.7e308
char values are actually stores as integers -128 to 127 which represents the ASCII value of the character.
Using this statement you can rename a data type in order to make it easier to use.
typedef unsigned char xchar;
Not only used to output numbers and character stings but also used to format output.
Output is formatted using escape sequences, a backslash followed by a character.
Commonly used escape sequences.
\n – The newline character moves the cursor to the next line.
\t – The tab sequence inserts a tab between the desired characters.
Numbers are formatted using format specifiers.
+ - Addition
- - Subtraction
* - Multiplication
/ - Division
% - Modulus (Remainder of Division operation)
== - Are two values equal to one another
< - Greater than
<= - Greater Then or Equal to
> - Less than
>= - Less than or Equal to
!= Not Equal to
( ) – Parenthesis, everything inside the parenthesis is completed first
^ - Exponent
% - Modulus
*, / - Multiplication, Division
+, - - Addition, Subtraction
Sum = 0
Sum = VarA + VarB
These are both statements that assign a value to the Sum variable
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”);
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”);
printf(“Opps You Did This Instead/n”);
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.
printf(“It’s a 1/n”);
printf(“It’s a 2/n”);
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.
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
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.
Standard Pre-Test structure of a while loop. While the condition is true then execute the statement or statements.
while (condition is true)
A post-test structure that executes the body of the loop at least once the second repetition dependent on the outcome of the test.
} while (conditon)
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)
Functions are called using the function name and the arguments or data that is sent to the function.
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.
A function is defined by its header which his located at the top of the function and is similar to the function declaration.
void Function(Value1, value2) --- Header
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.
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.
How will the new system work what procedures and functions will be used what order will the operations take
The program is actuality developed, tested, debugged and refined
The program is changed according to business needs and any problems that were missed in testing are corrected