This document provides an overview of the C programming language. It discusses that C is a popular system programming language developed for UNIX, and is similar to assembly. It describes the main components of a C program, including functions, variables, data types, and control statements. It also explains some key C concepts like tokens, keywords, data types, storage specifiers, and the build process that compiles C source code into an executable program.
3. Copyright@Embedkari
Overview
●
Most popular system programming language
●
Developed for UNIX. Linux & MySQL are written in C
●
Nearest to Assembly
●
Install Eclipse IDE from Embedkari Toolbox
–
Text Editor,Compiler,Assemblet,Linker and Debugge
4. Copyright@Embedkari
Programming Language
●
Program is a set of pre-defined instructions to a device/cpu
●
Lets take an example of normal language we use for communicatiion
–
Mr A ask a fast food person Mr B
–
Give me “one large Pizza”
–
Here Give Me is instruction and rest is data
–
The data itself has three parts
●
Quantity , Size , Item description
–
Mr B has to decode both instruction and data elements, Then act
accordingly. Mr B may also check payment status
–
Mr B is already trained to do the required action
–
Now one can replace Mr B with a ML trained Robot OR A pre-
programmed Vending machine
–
There may be another customer Mr C with different order and item
–
5. Copyright@Embedkari
Program Components
●
Group of instructions working on data
–
Functions
●
Data can be constant or variable at run time
–
Variables
●
Different kind of data like numbers, characters,strings
etc
–
Data Type
●
Different actions are possible based on the conditions
set for input data
–
Control statements & Expressions
7. Copyright@Embedkari
Token
●
Token is the smallest element of C program for Compiler
–
Keywords
–
Identifiers
–
Constants
–
Strings
–
Special Symbols
–
Operators
●
Keywords are pre-defined or reserved words
8. Copyright@Embedkari
Keywords-32
●
Primitive Data Types and related Keywords (8)
–
int long double float short char unsigned signed
●
Custom Data Types Related (3)
–
struct enum typedef
●
Control statements (12)
goto if else do while for
–
return switch case break continue default
●
Storage specifiers(4)
–
auto register static extern
●
Type Qualifiers(2) const volatile
●
Misc(3) : void sizeof union
●
Note: There are some additional reserve words added C99 onwards
–
9. Copyright@Embedkari
Data Type size @ARM ABI
C Type Machine Type Size
char unsigned byte 1
unsigned char unsigned byte 1
signed char signed byte 1
[signed]short signed halfword 2
unsigned short unsigned halfword 2
[signed] int signed word 4
unsigned int unsigned word 4
[signed] long signed word 4
unsigned long unsigned word 4
[signed] long long signed double-word 8
unsigned long long unsigned double-word 8
float single precision (IEEE 754) 4
double double precision (IEEE 754) 8
Long double double precision (IEEE 754) 8
10. Copyright@Embedkari
Storage Specifiers
●
auto (default)
–
Local variable with local life time
●
extern or global variable
–
Variable defined outside function will have global scope
●
static
–
Preserve this variable even after its scope ends
●
register,
–
This variable has to be stored in CPU register. Variables used often can
be defined in this category from performance perspective. But keep in
mind the limited cpu registers
●
11. Copyright@Embedkari
Exercise : Data Types and Storage
Classifiers
●
Define variables based on different storage classifiers and data type
●
Check size of data type defined
●
Check default initial value and memory location of different storage
classifiers
●
#include <stdio.h> //Pre-processor
//This is First C Program
–
int main() {
–
printf("Hello, World! n"); //printf() function
–
return 0;
–
}
●
12. Copyright@Embedkari
THANKS
If you found this information usefule < Please
like this video AND subscribe to
www.youtube.com/c/embedkari
Embedded Career Information :
www.facebook.com/embedkari
Blog:www.embedkari.com