SlideShare a Scribd company logo
C_Programming
First Session
ENG. KEROLES SHENOUDA
1
Why C, and not assembly language?
 While assembly language can provide speed and maximum control of the program, C
provides portability.
 Different processors are programmed using different Assembly languages and having to
choose and learn only one of them is too arbitrary. In fact, one of the main strengths of C is
that it combines universality and portability across various computer architectures while
retaining most of the control of the hardware provided by assembly language.
 For example, C programs can be compiled and run on the HP 50g calculator (ARM
processor), the TI-89 calculator (68000 processor), Palm OS Cobalt smartphones (ARM
processor), the original iMac (PowerPC), the Arduino (Atmel AVR), and the Intel iMac (Intel
Core 2 Duo). Each of these devices has its own assembly language that is completely
incompatible with the assembly language of any other.
 Assembly, while extremely powerful, is simply too difficult to program large applications and
hard to read or interpret in a logical way. C is a compiled language, which creates fast and
efficient executable files. It is also a small "what you see is all you get" language: a C
statement corresponds to at most a handful of assembly statements, everything else is
provided by library functions.
2
Why C, and not another language?
 The primary design of C is to produce portable code while maintaining
performance and minimizing footprint (CPU time, memory, disk I/O, etc.). This
is useful for operating systems, embedded systems or other programs where
performance matters a lot ("high-level" interface would affect performance)
 One powerful reason is memory allocation. Unlike most programming
languages, C allows the programmer to write directly to memory.
 C gives control over the memory layout of data structures
 Moreover dynamic memory allocation is under the control of the programmer
(which also means that memory deallocation has to be done by the
programmer).
 While Perl, PHP, Python and Ruby may be powerful and support many features
not provided by default in C
3
Compilation Process 4
C - Environment Setup 5
IDE + Compiler
Install Eclipse C/C++ Development Tool (CDT)
Java Downloads for All Operating Systems
1. Install MinGW GCC
Minimalist GNU for Windows
https://sourceforge.net/projects/mingw/file
s/
2. Cygwin GCC
https://www.cygwin.com/setup-x86.exe
Cygwin is:
a large collection of GNU and Open Source tools
which provide functionality similar to a Linux
distribution on Windows.
a DLL (cygwin1.dll) which provides substantial
POSIX API functionality.
Install MinGW GCC 6
Press Apply to all
Install MinGW GCC
Minimalist GNU for Windows
https://sourceforge.net/projects/mingw/files/
Install MinGW GCC 7
Wait until downloading Complete
Install MinGW GCC 8
Install MinGW GCC 9
En you can see all the basic packets
became green
Install MinGW GCC 10
Then you can see the
gcc and gdb and other
binary utilities installed
(Native Toolchain )
Eclipse C/C++ (CDT) 11
 Install Eclipse C/C++ Development Tool (CDT)
 Java Downloads for All Operating Systems
Write first C Program
 Open Eclipse
 Chose an empty Directory For eclipse workspace
12
Write first C Program 13
Write first C Program 14
Write first C Program 15
Write first C Program 16
Write first C Program (Build the
Application)
17
Write first C Program (Run the
Application)
18
After Press Run,
Then you will see the
Printf message appearing
On the Console
Write first C Program (Debug the
Application)
19
Write first C Program (Debug the
Application)
20
Stopped
on the
Breakpoint
Write first C Program (Debug the
Application)
21
GCC Compilation Process
 Pre-processing: via the GNU C Preprocessor (cpp.exe), which includes the
headers (#include) and expands the macros (#define).
 cpp hello.c > hello.i
The resultant intermediate file "hello.i" contains the expanded source code.
 Compilation: The compiler compiles the pre-processed source code into
assembly code for a specific processor.
 gcc -S hello.i
The -S option specifies to produce assembly code, instead of object code. The
resultant assembly file is "hello.s".
 Assembly: The assembler (as.exe) converts the assembly code into machine
code in the object file "hello.o".
 as -o hello.o hello.s
 Linker: Finally, the linker (ld.exe) links the object code with the library code
to produce an executable file "hello.exe".
 ld -o hello.exe hello.o ...libraries...
22
GCC Compilation Process LAB 1
on Ubuntu
23
GCC Compilation Process LAB 1
on Ubuntu
24
GCC Compilation Process LAB 1
on Ubuntu
25
GCC Compilation Process LAB 1
on Ubuntu
26
GCC Compilation Process LAB 1
on Ubuntu
27
Compilation Process 28
First C Program “Hello Program” 29
30
31
Chapter 1:
Introduction
HTTPS://DRIVE.GOOGLE.COM/FILE/D/0B7KUSGPVTWFLAEZDWLZEZM0XS0U/VIEW
32
C Programming Data Types 33
Refrences
 GCC and Make Compiling, Linking and Building C/C++ Applications
 C Programming/Why learn C?
 Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse
Edition
34

More Related Content

PDF
PDF
First session quiz
PPT
Embedded _c_
PDF
C programming session9 -
PPT
Embedded c program and programming structure for beginners
PDF
Embedded c lab and keil c manual
PPT
Embedded c programming22 for fdp
PPTX
Embedded c
First session quiz
Embedded _c_
C programming session9 -
Embedded c program and programming structure for beginners
Embedded c lab and keil c manual
Embedded c programming22 for fdp
Embedded c

What's hot (19)

PDF
C programming session10
PDF
Embedded C - Lecture 1
PDF
Embedded c
PDF
Embedded C programming based on 8051 microcontroller
PPTX
Embedded C programming session10
PDF
C programming session6
DOCX
Embedded System Practical manual (1)
PDF
Writing c code for the 8051
PPTX
PDF
Machine language
PPTX
Loader and Its types
PDF
C programming part2
PPTX
Embedded C workshop
PPTX
Embedded c c++ programming fundamentals master
PPT
Introduction to c programming
PDF
Pt 51 ver-1.3_user_manual
PPTX
Introduction to Assembly Language Programming
PPT
Lec 01 basic concepts
PDF
Embedded concepts
C programming session10
Embedded C - Lecture 1
Embedded c
Embedded C programming based on 8051 microcontroller
Embedded C programming session10
C programming session6
Embedded System Practical manual (1)
Writing c code for the 8051
Machine language
Loader and Its types
C programming part2
Embedded C workshop
Embedded c c++ programming fundamentals master
Introduction to c programming
Pt 51 ver-1.3_user_manual
Introduction to Assembly Language Programming
Lec 01 basic concepts
Embedded concepts
Ad

Viewers also liked (20)

PDF
C programming session3
PDF
C programming part4
PDF
Automative basics v3
PDF
Microcontroller part 1
PDF
K vector embedded_linux_workshop
PDF
C programming session7
PDF
Microcontroller part 4
PDF
Microcontroller part 3
PDF
C programming session8
PDF
Microcontroller part 2
PDF
Microcontroller part 5
PDF
C programming part2
PDF
C programming part4
PDF
C programming session5
PDF
Microcontroller part 1
PDF
Microcontroller part 4
PDF
Microcontroller part 8_v1
PDF
Microcontroller part 3
PDF
Microcontroller part 6_v1
PDF
Microcontroller part 2
C programming session3
C programming part4
Automative basics v3
Microcontroller part 1
K vector embedded_linux_workshop
C programming session7
Microcontroller part 4
Microcontroller part 3
C programming session8
Microcontroller part 2
Microcontroller part 5
C programming part2
C programming part4
C programming session5
Microcontroller part 1
Microcontroller part 4
Microcontroller part 8_v1
Microcontroller part 3
Microcontroller part 6_v1
Microcontroller part 2
Ad

Similar to C programming first_session (20)

PPTX
Introduction to c language
PPTX
C101 – Intro to Programming with C
PPTX
C language myths & secrets
PPTX
Introduction to C Programming
PPTX
Unit-1_c.pptx you from the heart of the day revision
PPTX
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
PDF
Fundamental of Information Technology - UNIT 7
DOC
Introduction to C Programming - TCCI.doc
PPTX
C++ l 1
PPT
Introduction
DOC
Basic c
PDF
GNU Compiler Collection - August 2005
PPTX
Day 1 - Introduction to C.pptx
PPT
C_Intro.ppt
DOCX
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
PDF
Introduction to c programming
PPTX
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
PPTX
Introduction to c
Introduction to c language
C101 – Intro to Programming with C
C language myths & secrets
Introduction to C Programming
Unit-1_c.pptx you from the heart of the day revision
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
Fundamental of Information Technology - UNIT 7
Introduction to C Programming - TCCI.doc
C++ l 1
Introduction
Basic c
GNU Compiler Collection - August 2005
Day 1 - Introduction to C.pptx
C_Intro.ppt
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
Introduction to c programming
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
Introduction to c

More from Keroles karam khalil (20)

PDF
C basics quiz part 1_solution
PDF
Autosar Basics hand book_v1
PDF
Automotive embedded systems part6 v2
PDF
Automotive embedded systems part5 v2
PDF
Automotive embedded systems part7 v1
PDF
Automotive embedded systems part6 v1
PDF
Automotive embedded systems part5 v1
PDF
Automotive embedded systems part4 v1
PDF
Automotive embedded systems part3 v1
PDF
Automotive embedded systems part2 v1
PDF
Automotive embedded systems part1 v1
PDF
Automotive embedded systems part8 v1
DOCX
PDF
Homework 5 solution
PDF
C programming session8
PDF
PDF
PDF
C programming session7
C basics quiz part 1_solution
Autosar Basics hand book_v1
Automotive embedded systems part6 v2
Automotive embedded systems part5 v2
Automotive embedded systems part7 v1
Automotive embedded systems part6 v1
Automotive embedded systems part5 v1
Automotive embedded systems part4 v1
Automotive embedded systems part3 v1
Automotive embedded systems part2 v1
Automotive embedded systems part1 v1
Automotive embedded systems part8 v1
Homework 5 solution
C programming session8
C programming session7

Recently uploaded (20)

PDF
Well-logging-methods_new................
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
PPT on Performance Review to get promotions
DOCX
573137875-Attendance-Management-System-original
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
composite construction of structures.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Project quality management in manufacturing
PPTX
Sustainable Sites - Green Building Construction
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Artificial Intelligence
Well-logging-methods_new................
Internet of Things (IOT) - A guide to understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPT on Performance Review to get promotions
573137875-Attendance-Management-System-original
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
composite construction of structures.pdf
OOP with Java - Java Introduction (Basics)
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Project quality management in manufacturing
Sustainable Sites - Green Building Construction
CH1 Production IntroductoryConcepts.pptx
Artificial Intelligence

C programming first_session

  • 2. Why C, and not assembly language?  While assembly language can provide speed and maximum control of the program, C provides portability.  Different processors are programmed using different Assembly languages and having to choose and learn only one of them is too arbitrary. In fact, one of the main strengths of C is that it combines universality and portability across various computer architectures while retaining most of the control of the hardware provided by assembly language.  For example, C programs can be compiled and run on the HP 50g calculator (ARM processor), the TI-89 calculator (68000 processor), Palm OS Cobalt smartphones (ARM processor), the original iMac (PowerPC), the Arduino (Atmel AVR), and the Intel iMac (Intel Core 2 Duo). Each of these devices has its own assembly language that is completely incompatible with the assembly language of any other.  Assembly, while extremely powerful, is simply too difficult to program large applications and hard to read or interpret in a logical way. C is a compiled language, which creates fast and efficient executable files. It is also a small "what you see is all you get" language: a C statement corresponds to at most a handful of assembly statements, everything else is provided by library functions. 2
  • 3. Why C, and not another language?  The primary design of C is to produce portable code while maintaining performance and minimizing footprint (CPU time, memory, disk I/O, etc.). This is useful for operating systems, embedded systems or other programs where performance matters a lot ("high-level" interface would affect performance)  One powerful reason is memory allocation. Unlike most programming languages, C allows the programmer to write directly to memory.  C gives control over the memory layout of data structures  Moreover dynamic memory allocation is under the control of the programmer (which also means that memory deallocation has to be done by the programmer).  While Perl, PHP, Python and Ruby may be powerful and support many features not provided by default in C 3
  • 5. C - Environment Setup 5 IDE + Compiler Install Eclipse C/C++ Development Tool (CDT) Java Downloads for All Operating Systems 1. Install MinGW GCC Minimalist GNU for Windows https://sourceforge.net/projects/mingw/file s/ 2. Cygwin GCC https://www.cygwin.com/setup-x86.exe Cygwin is: a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows. a DLL (cygwin1.dll) which provides substantial POSIX API functionality.
  • 6. Install MinGW GCC 6 Press Apply to all Install MinGW GCC Minimalist GNU for Windows https://sourceforge.net/projects/mingw/files/
  • 7. Install MinGW GCC 7 Wait until downloading Complete
  • 9. Install MinGW GCC 9 En you can see all the basic packets became green
  • 10. Install MinGW GCC 10 Then you can see the gcc and gdb and other binary utilities installed (Native Toolchain )
  • 11. Eclipse C/C++ (CDT) 11  Install Eclipse C/C++ Development Tool (CDT)  Java Downloads for All Operating Systems
  • 12. Write first C Program  Open Eclipse  Chose an empty Directory For eclipse workspace 12
  • 13. Write first C Program 13
  • 14. Write first C Program 14
  • 15. Write first C Program 15
  • 16. Write first C Program 16
  • 17. Write first C Program (Build the Application) 17
  • 18. Write first C Program (Run the Application) 18 After Press Run, Then you will see the Printf message appearing On the Console
  • 19. Write first C Program (Debug the Application) 19
  • 20. Write first C Program (Debug the Application) 20 Stopped on the Breakpoint
  • 21. Write first C Program (Debug the Application) 21
  • 22. GCC Compilation Process  Pre-processing: via the GNU C Preprocessor (cpp.exe), which includes the headers (#include) and expands the macros (#define).  cpp hello.c > hello.i The resultant intermediate file "hello.i" contains the expanded source code.  Compilation: The compiler compiles the pre-processed source code into assembly code for a specific processor.  gcc -S hello.i The -S option specifies to produce assembly code, instead of object code. The resultant assembly file is "hello.s".  Assembly: The assembler (as.exe) converts the assembly code into machine code in the object file "hello.o".  as -o hello.o hello.s  Linker: Finally, the linker (ld.exe) links the object code with the library code to produce an executable file "hello.exe".  ld -o hello.exe hello.o ...libraries... 22
  • 23. GCC Compilation Process LAB 1 on Ubuntu 23
  • 24. GCC Compilation Process LAB 1 on Ubuntu 24
  • 25. GCC Compilation Process LAB 1 on Ubuntu 25
  • 26. GCC Compilation Process LAB 1 on Ubuntu 26
  • 27. GCC Compilation Process LAB 1 on Ubuntu 27
  • 29. First C Program “Hello Program” 29
  • 30. 30
  • 31. 31
  • 33. C Programming Data Types 33
  • 34. Refrences  GCC and Make Compiling, Linking and Building C/C++ Applications  C Programming/Why learn C?  Getting Started with C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition 34