Академический Документы
Профессиональный Документы
Культура Документы
Below C Level
Origin
Characteristics
- Programming languages have different levels, depending on how they resemble human
languages
1. Low-level Languages
2. Mid-level Languages
3. High-level Languages
ADVANTAGES:
High-level Low-level
M
I
D
- - runs programs faster
- easier to implement L - produces smaller program
E size
V
E
L
Mid-level Language
- examines each
- reads the instruction instruction - translates the
from the code information
(tells errors)
Development Cycle
1. Save!
2. Compile and Link!
3. Run!
4. Do it Again!
Common Errors
1. Wrong file extension
2. Using a forward slash (\) when a blackslash (/) is required
3. Forget to put on & on arguments, causes SEGMENTATION FAULT
SEGMENTATION FAULT – lacking argument, parameter, or variable
4. Missing closing and terminating characters, causes SYNTAX ERROR
- omitting a semicolon (signifies end of line) or a closing brace
- omitting quotation character
intmain (){
printf (“hello world!\n”);
return 0;
}
#include – directory
- instructs the compiler to include another source file
<stdio.h> or “stdio.h” – header file (.h)
- Provide protoype declarations for library functions
Libraries:
<stdio.h>
- standard input output
<math.h>
- math operations
<stdlib.h>
- standard library
<string.h>
- string manipulation
intmain(){
} - main function
- Curly brackets close body
- Performs the principal function of a program
Variable Declaration
Variables
- Temporary holders of values with a specified data type.
Data Type
- size and range of values and operations
Data Types in C
Data Type Name Format Specifier Description
void Void Absence of type
int Integer %d or %i Whole numbers
char Character %c Letters on symbols
float Float %f Floating point numbers
(six decimal places)
double Double %lf Floating point numbers
(fifteen decimal places)
Reserved Words
- Cannot be declared as variables; cannot be used as variable names.
EX: return
Comments
// - ignores a line
/* */ - used for multi-line comments
EX:
/*
This is a function in C
*/
//comment
Printing a Statement
In Pseudocode In C
DISPLAY “hello world” printf(“hello world”);
Getting an Input