SlideShare a Scribd company logo
Computer Programming In C
COMPUTER
Architecture of Computer
• Input Unit
• Central Processing Unit
• Output Unit
INPUT DEVICES
OUTPUT DEVICES
Secondary Memory
Primary Memory
Control Unit (CU)
Arithmetic and Logical
Unit (ALU)
Input
unit
output
unit
Memory
Data Information
Central Processing Unit (CPU)
Memory
Primary
RAM ROM
Secondary
Types of Memory
Different Units of Memory
Data Measurement Size
Bit Single Binary Digit (1 or 0)
1 Byte 8 bits (01001011)
1 Kilobyte(KB) 1024 Bytes
1 Megabyte(MB) 1024 Kilobytes
1 Gigabyte(GB) 1024 Megabytes
1 Terabyte(TB) 1024 Gigabytes
1 Peta byte(PB) 1024 Terabytes
1 Exabyte(EX) 1024 Petabytes
Computer Programming In C.pptx
Software
Software is a collection of programs and data that tell a computer how
to work.
Computer software can be classified
into two types based on its utility
1. Application Software
2. System Software
Program
A computer program is a collection of instructions
that can be executed by a computer to perform a
specific task.
A computer program is usually written by a
computer programmer in a programming
language.
Ex.- C, C++,Python, .net
Computer Programming In C.pptx
Chapter 1
Basics of C
Contents…
• History of C
• Features of C
• Importance of C
• About procedural language
• Role of compiler, interpreter
• Structure of C program
• Algorithm
• Flow chart
• Debugging of C program
Computer Programming In C.pptx
Computer Programming In C.pptx
Features of C
1) Simple
C is a simple language in the sense that it provides a structured approach (to break the problem
into parts), the rich set of library functions, data types, etc.
2) Machine Independent or Portable
Unlike assembly language, c programs can be executed on different machines with some
machine specific changes. Therefore, C is a machine independent language.
3) Mid-level programming language
Although, C is intended to do low-level programming. It is used to develop system applications
such as kernel, driver, etc. It also supports the features of a high-level language. That is why
it is known as mid-level language.
4) Structured programming language
C is a structured programming language in the sense that we can break the program into parts
using functions. So, it is easy to understand and modify. Functions also provide code
reusability.
5) Rich Library
C provides a lot of inbuilt functions that make the development fast.
6) Memory Management
It supports the feature of dynamic memory allocation. In C language,
we can free the allocated memory at any time by calling
the free() function.
7) Speed
The compilation and execution time of C language is fast since there
are lesser inbuilt functions and hence the lesser overhead.
8) Pointer
C provides the feature of pointers. We can directly interact with the
memory by using the pointers. We can use pointers for memory,
structures, functions, array, etc.
9) Recursion
In C, we can call the function within the function. It provides code
reusability for every function. Recursion enables us to use the
approach of backtracking.
10) Extensible
C language is extensible because it can easily adopt new features.
Importance of C
• C is highly portable language i.e. code written in one
machine can be moved to other which is
very important and powerful feature.
• C supports low level features like bit level programming and
direct access to memory using pointer which is very useful
for managing resource efficiently.
• Also used for scripting system applications which form a
major part of Windows, UNIX, and Linux operating system.
• C programming language is so popular and
used so widely because Programmers have opportunities to
control how, when, and where to allocate and deallocate
memory. Memory is allocated statically, automatically or
dynamically.
• C is a general-purpose programming language and can
efficiently work on enterprise applications, games,
graphics, and applications requiring calculations, etc.
About Procedural Language
• A procedural language is a computer programming
language that follows, in order, a set of commands.
• Examples of computer procedural languages
are BASIC, C, FORTRAN, Java, and Pascal.
• The focus of procedural programming is to break down
a programming task into a collection of variables, data
structures, and subroutines, whereas in object-
oriented programming it is to break down
a programming task into objects that expose behavior
(methods) and data (members or attributes) using
interfaces.
Role of Compiler
• Compiler, computer software that translates
(compiles) source code written in a high-level
language (e.g., C) into a set of machine-language
instructions that can be understood by a digital
computer's CPU.
• Compilers are very large programs, with error-
checking and other abilities.
• Compiler checks source code for syntactical and
structural errors and if source code is error free
then it generates object code.
• The GNU Compiler Collection (GCC) is one
such compiler for the C language.
Role of Interpreter
• Computer software that translates source code
written in a high-level language into a set of
machine-language instructions that can be
understood by a digital computer's CPU.
• Interpreter is a computer program that directly
executes instructions written in a programming
or scripting language, without requiring them
previously to have been compiled into a machine
language program.
• Program execution is slow.
Interpreter
• Translates program one
statement at a time.
• Interpreters usually take less
amount of time to analyze the
source code. However, the
overall execution time is
comparatively slower than
compilers.
• No Object Code is generated,
hence are memory efficient.
• Programming languages like
JavaScript, Python, Ruby use
interpreters.
Compiler
• Scans the entire program and
translates it as a whole into
machine code.
• Compilers usually take a large
amount of time to analyze the
source code. However, the
overall execution time is
comparatively faster than
interpreters.
• Generates Object Code which
further requires linking, hence
requires more memory.
• Programming languages like C,
C++, Java use compilers.
Structure of C program
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int no1,no2;
printf(“Enter nos”);
getch();
}
Preprocessor Directives:-
• It is written at the beginning of program.
• These lines not end with semicolon.
• Only one Preprocessor Directive can appear in
one line.
• #include <stdio.h> includes the standard input
output library functions. The printf() function
is defined in stdio.h .
• #include <conio.h> includes the console input
output library functions. The clrscr() function
is defined in conio.h .
Global Declaration Part
• This part of the code is the part where the
global variables are declared.
• All the global variable used are declared in this
part.
• The user-defined functions are also declared
in this part of the code.
void main()
• The main() function is the entry point of every program in c
language.
• It is required in all c programs.
• Only one main() function in one program.
• It begins with the curly brackets and ends with the curly close
bracket.
• Each main function contains 2 parts-
1. Declaration part
It is the part where all the variables are declared.
2. Execution part
Each line is statement and terminated by semicolon.
E.X.- The printf() function is used to print data on the console.
Both the declaration and execution part are inside the curly
braces.
Building Executable version of C
program
• Create Source Code(.c)
• Pre-processing- The preprocessor takes the
source code as an input, and it removes all the
comments from the source code.
• Compilation- The compiler converts this code
into assembly code.
Assembly- The assembly code is converted into
object code by using an assembler. (.obj)
• Linking- Linker combine the object code of library
files with the object code of our program. The
output of the linker is the executable file. (.exe)
Algorithm
• It is logical sequence of steps prepared for
solving problem.
• It is tool to write job in simple steps in English
language.
• It is not program.
• It guides programmer to prepare the program.
Efficient Algorithm should have
following Characteristics
1. It should be easy and simple in language.
2. It should not repeat task again and again.
3. Every step must be accurate & complete in itself.
4. It can be easily modified if necessary.
5. It should be easily understandable to others & steps
should be clear & concise.
6. It should be economical in use of computer time,
computer storage and peripherals.
7. It should be correct for clearly defined situations.
• Algorithm to exchange the value of two
variables.
Suppose if A and B are two variables.
1) Store the value of A in X.
2) Transfer B value to A.
3) Transfer X to B.
Flow Chart
• After preparing algorithm for given task it can
be presented in pictorial form.
• The method used to represent algorithm in
pictorial form with standard meaningful
symbols is known as flow chart.
Symbols
• Rectangular with rounded
corners to specify START &
STOP known as terminal. It
is usually used at start and
end of program.
• Parallelogram to
represent input &output
operation. It is also known
as input /output symbol.
START STOP
PRINT INPUT
READ
• Rectangle is used to
represent processing or
calculating part.
• Diamond symbol is
used to present
decision making step in
form of question &
logical answer, it is
known as “Decision
Box.”
s=a+b+c
is
Y=0?
• Arrows are used to
indicate direction of flow
of program process.
• Small Circle is used to
connect incomplete flow
chart to its remaining
part. It is known as
connector. Normally it is
used at end of page
where flow chart breaks
and situations where flow
lines cross each other.
A
A
Rules to draw Flow Chart
1) The standard symbols should be used.
2) The arrows should be used represent
direction of flow.
3) Flow lines should not cross each other.
4) Program flow should be top to bottom.
Computer Programming In C.pptx

More Related Content

PPTX
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
PDF
Module4.pdf ,...................................
PPTX
Chapter 1 Introduction to C .pptx
PDF
X-CS-8.0 Programming in C Language 2022-2023.pdf
PPTX
Unit 1 part1 Introduction of Compiler Design.pptx
PPTX
Lecture 1 Introduction.pptx hfjsh huwhf uwej wiuehfi w
PPTX
Unit ii
PPTX
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
Module4.pdf ,...................................
Chapter 1 Introduction to C .pptx
X-CS-8.0 Programming in C Language 2022-2023.pdf
Unit 1 part1 Introduction of Compiler Design.pptx
Lecture 1 Introduction.pptx hfjsh huwhf uwej wiuehfi w
Unit ii
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY

Similar to Computer Programming In C.pptx (20)

PPTX
PPTX
PPTX
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
PPTX
Programming in C
PPTX
Programming in c
PPTX
Embedded c c++ programming fundamentals master
PPTX
week 2 - INTRO TO PROGRAMMING.pptx
PPT
01CHAP_1.PPT
PPTX
01-PROGRAMMING introA of the class name. Pptx
PPTX
Introduction_to_Programming.pptx
PPTX
Compiler Design Introduction
PPTX
Introduction to programming c
PPTX
Best Computer Institute in Pitampura, Delhi, Learn from Industry Experts.
PPTX
lecture Slides - Week 1.programming fundamentals
PDF
Chapter1.pdf
PPTX
Introduction to C Programming
PDF
PPTX
lec 1.pptx
PPTX
Compiler Construction Introduction Slide PPT
PPTX
Basics of C Lecture 2[16097].pptx
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
Programming in C
Programming in c
Embedded c c++ programming fundamentals master
week 2 - INTRO TO PROGRAMMING.pptx
01CHAP_1.PPT
01-PROGRAMMING introA of the class name. Pptx
Introduction_to_Programming.pptx
Compiler Design Introduction
Introduction to programming c
Best Computer Institute in Pitampura, Delhi, Learn from Industry Experts.
lecture Slides - Week 1.programming fundamentals
Chapter1.pdf
Introduction to C Programming
lec 1.pptx
Compiler Construction Introduction Slide PPT
Basics of C Lecture 2[16097].pptx
Ad

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
composite construction of structures.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Lesson 3_Tessellation.pptx finite Mathematics
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Sustainable Sites - Green Building Construction
Operating System & Kernel Study Guide-1 - converted.pdf
Foundation to blockchain - A guide to Blockchain Tech
Internet of Things (IOT) - A guide to understanding
composite construction of structures.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Embodied AI: Ushering in the Next Era of Intelligent Systems
UNIT 4 Total Quality Management .pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CH1 Production IntroductoryConcepts.pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Ad

Computer Programming In C.pptx

  • 3. Architecture of Computer • Input Unit • Central Processing Unit • Output Unit
  • 6. Secondary Memory Primary Memory Control Unit (CU) Arithmetic and Logical Unit (ALU) Input unit output unit Memory Data Information Central Processing Unit (CPU)
  • 8. Different Units of Memory Data Measurement Size Bit Single Binary Digit (1 or 0) 1 Byte 8 bits (01001011) 1 Kilobyte(KB) 1024 Bytes 1 Megabyte(MB) 1024 Kilobytes 1 Gigabyte(GB) 1024 Megabytes 1 Terabyte(TB) 1024 Gigabytes 1 Peta byte(PB) 1024 Terabytes 1 Exabyte(EX) 1024 Petabytes
  • 10. Software Software is a collection of programs and data that tell a computer how to work.
  • 11. Computer software can be classified into two types based on its utility 1. Application Software 2. System Software
  • 12. Program A computer program is a collection of instructions that can be executed by a computer to perform a specific task. A computer program is usually written by a computer programmer in a programming language. Ex.- C, C++,Python, .net
  • 15. Contents… • History of C • Features of C • Importance of C • About procedural language • Role of compiler, interpreter • Structure of C program • Algorithm • Flow chart • Debugging of C program
  • 18. Features of C 1) Simple C is a simple language in the sense that it provides a structured approach (to break the problem into parts), the rich set of library functions, data types, etc. 2) Machine Independent or Portable Unlike assembly language, c programs can be executed on different machines with some machine specific changes. Therefore, C is a machine independent language. 3) Mid-level programming language Although, C is intended to do low-level programming. It is used to develop system applications such as kernel, driver, etc. It also supports the features of a high-level language. That is why it is known as mid-level language. 4) Structured programming language C is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify. Functions also provide code reusability.
  • 19. 5) Rich Library C provides a lot of inbuilt functions that make the development fast. 6) Memory Management It supports the feature of dynamic memory allocation. In C language, we can free the allocated memory at any time by calling the free() function. 7) Speed The compilation and execution time of C language is fast since there are lesser inbuilt functions and hence the lesser overhead. 8) Pointer C provides the feature of pointers. We can directly interact with the memory by using the pointers. We can use pointers for memory, structures, functions, array, etc. 9) Recursion In C, we can call the function within the function. It provides code reusability for every function. Recursion enables us to use the approach of backtracking. 10) Extensible C language is extensible because it can easily adopt new features.
  • 20. Importance of C • C is highly portable language i.e. code written in one machine can be moved to other which is very important and powerful feature. • C supports low level features like bit level programming and direct access to memory using pointer which is very useful for managing resource efficiently. • Also used for scripting system applications which form a major part of Windows, UNIX, and Linux operating system. • C programming language is so popular and used so widely because Programmers have opportunities to control how, when, and where to allocate and deallocate memory. Memory is allocated statically, automatically or dynamically. • C is a general-purpose programming language and can efficiently work on enterprise applications, games, graphics, and applications requiring calculations, etc.
  • 21. About Procedural Language • A procedural language is a computer programming language that follows, in order, a set of commands. • Examples of computer procedural languages are BASIC, C, FORTRAN, Java, and Pascal. • The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object- oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces.
  • 22. Role of Compiler • Compiler, computer software that translates (compiles) source code written in a high-level language (e.g., C) into a set of machine-language instructions that can be understood by a digital computer's CPU. • Compilers are very large programs, with error- checking and other abilities. • Compiler checks source code for syntactical and structural errors and if source code is error free then it generates object code. • The GNU Compiler Collection (GCC) is one such compiler for the C language.
  • 23. Role of Interpreter • Computer software that translates source code written in a high-level language into a set of machine-language instructions that can be understood by a digital computer's CPU. • Interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. • Program execution is slow.
  • 24. Interpreter • Translates program one statement at a time. • Interpreters usually take less amount of time to analyze the source code. However, the overall execution time is comparatively slower than compilers. • No Object Code is generated, hence are memory efficient. • Programming languages like JavaScript, Python, Ruby use interpreters. Compiler • Scans the entire program and translates it as a whole into machine code. • Compilers usually take a large amount of time to analyze the source code. However, the overall execution time is comparatively faster than interpreters. • Generates Object Code which further requires linking, hence requires more memory. • Programming languages like C, C++, Java use compilers.
  • 25. Structure of C program #include<stdio.h> #include<conio.h> void main() { clrscr(); int no1,no2; printf(“Enter nos”); getch(); }
  • 26. Preprocessor Directives:- • It is written at the beginning of program. • These lines not end with semicolon. • Only one Preprocessor Directive can appear in one line. • #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h . • #include <conio.h> includes the console input output library functions. The clrscr() function is defined in conio.h .
  • 27. Global Declaration Part • This part of the code is the part where the global variables are declared. • All the global variable used are declared in this part. • The user-defined functions are also declared in this part of the code.
  • 28. void main() • The main() function is the entry point of every program in c language. • It is required in all c programs. • Only one main() function in one program. • It begins with the curly brackets and ends with the curly close bracket. • Each main function contains 2 parts- 1. Declaration part It is the part where all the variables are declared. 2. Execution part Each line is statement and terminated by semicolon. E.X.- The printf() function is used to print data on the console. Both the declaration and execution part are inside the curly braces.
  • 29. Building Executable version of C program • Create Source Code(.c) • Pre-processing- The preprocessor takes the source code as an input, and it removes all the comments from the source code. • Compilation- The compiler converts this code into assembly code. Assembly- The assembly code is converted into object code by using an assembler. (.obj) • Linking- Linker combine the object code of library files with the object code of our program. The output of the linker is the executable file. (.exe)
  • 30. Algorithm • It is logical sequence of steps prepared for solving problem. • It is tool to write job in simple steps in English language. • It is not program. • It guides programmer to prepare the program.
  • 31. Efficient Algorithm should have following Characteristics 1. It should be easy and simple in language. 2. It should not repeat task again and again. 3. Every step must be accurate & complete in itself. 4. It can be easily modified if necessary. 5. It should be easily understandable to others & steps should be clear & concise. 6. It should be economical in use of computer time, computer storage and peripherals. 7. It should be correct for clearly defined situations.
  • 32. • Algorithm to exchange the value of two variables. Suppose if A and B are two variables. 1) Store the value of A in X. 2) Transfer B value to A. 3) Transfer X to B.
  • 33. Flow Chart • After preparing algorithm for given task it can be presented in pictorial form. • The method used to represent algorithm in pictorial form with standard meaningful symbols is known as flow chart.
  • 34. Symbols • Rectangular with rounded corners to specify START & STOP known as terminal. It is usually used at start and end of program. • Parallelogram to represent input &output operation. It is also known as input /output symbol. START STOP PRINT INPUT READ
  • 35. • Rectangle is used to represent processing or calculating part. • Diamond symbol is used to present decision making step in form of question & logical answer, it is known as “Decision Box.” s=a+b+c is Y=0?
  • 36. • Arrows are used to indicate direction of flow of program process. • Small Circle is used to connect incomplete flow chart to its remaining part. It is known as connector. Normally it is used at end of page where flow chart breaks and situations where flow lines cross each other. A A
  • 37. Rules to draw Flow Chart 1) The standard symbols should be used. 2) The arrows should be used represent direction of flow. 3) Flow lines should not cross each other. 4) Program flow should be top to bottom.