2. Computer Programming
Computer programming is the process of writing code to
facilitate specific actions in a computer, application or software
program, and instructs them on how to perform.
4. C Language
The C language is a basic programming language and it is a very popular
language, particularly used in embedded system ,game programming,
Because C language includes the additional packing of the C++, Every
programmer uses this language because it makes programs faster .
However the value of this language gives the reusability of C++ to get the
slight increase in performance with C language
5. Why to Learn C Programming?
• C programming language is a MUST for students and
working professionals to become a great Software
Engineer specially when they are working in Software
Development Domain. I will list down some of the key
advantages of learning C Programming:
• Easy to learn
• Structured language
• It produces efficient programs
• It can handle low-level activities
• It can be compiled on a variety of computer platforms
6. Facts about C
• C was invented to write an operating system called
UNIX.
• C is a successor of B language which was introduced
around the early 1970s.
• The language was formalized in 1988 by the American
National Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System
Programming Language.
• Most of the state-of-the-art software have been
implemented using C
9. “Structure of C Program”
Program has six section The six sections are
1. Documentation
2.Link
3. Definition
4. Global Declarations
5.Main functions
6. Subprograms
10.
11. 1.Documentation Section
the Documentation Section consists of a set of
comment lines giving the name of the
Programmer, date, and other details about the
program. The documentation section helps
anyone to get an overview of the program.
12. example
/*
* File Name: Helloworld.c
* Author: ABC(name of programmer)
* date: 25/11/2020
* description: a program to display hello world
* no input needed
*/
14. 2. Link Section
• The Link section provides instructions to the compiler to
link functions from the system library such as using the
#include directive.
• This part of the code is used to declare all the header files
that will be used in the program. This leads to the compiler
being told to link the header files to the system libraries.
Some Examples
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
15.
16. 3. Definition
All the symbolic constants are written in the
definition section by using the #define
directive.
Examples
#define PI=3.14
#define
17.
18. 4. Global Declarations
• Global Declaration Section contains the global
declaration of user-defined functions and
Variables. There are some variables that are
used in more than one function. Such
variables are called Global Variables and are
declared in the global declaration section that
is outside of all the functions
19.
20. 5.Main Sections
• Every C-programs needs to have the main
function. Each main function contains 2 parts.
A declaration part and an Execution part. The
declaration part is the part where all the
variables are declared. The execution part
begins with the curly brackets and ends with
the curly close bracket. Both the declaration
and execution part are inside the curly brace
21. 6. Subprogram Section
The subprogram section contains all the user-
defined functions that are used to perform a
specific task. These user-defined functions are
called in the main function. User-defined
functions are generally placed just after the
main() function, although they may appear in
any order
22.
23. Identifiers,
Identifiers are names for entities in a C program,
such as variables, arrays, functions, structures,
unions and labels. An identifier can be composed
only of uppercase, lowercase letters, underscore
and digits, but should start only with an alphabet
or an underscore. If the identifier is not used in
an external link process, then it is called as
internal. Example: Local variable. If the identifier
is used in an external link process, then it is called
as external. Example: Global variable
24. Rules for constructing identifiers
• 1. The first character in an identifier must be an
alphabet or an underscore and can be followed only by
any number alphabets, or digits or underscores.
2. They must not begin with a digit.
3. Uppercase and lowercase letters are distinct. That
is, identifiers are case sensitive.
4. Commas or blank spaces are not allowed within an
identifier.
5. Keywords cannot be used as an identifier.
6. Identifiers should not be of length more than 31
characters.
7. Identifiers must be meaningful, short, quickly and
easily typed and easily read
25. Valid
identifiers: total sum average _x
y_ mark_1 x1
Invalid identifiers
1x - begins with a digit
char - reserved word
x+y - special character
29. What are Data types in C
Programming?
In C programming, data types are just the same
what their name suggests. They represent the
kind of data to store. They are used to declare
several functions as well as variables in a
program
30.
31.
32. C – Constant
• C Constants are also like normal variables. But,
only difference is, their values can not be
modified by the program once they are
defined. Constants refer to fixed values. They
are also called as literals. Constants may be
belonging to any of the data type.
33.
34. Variable in C
• C variable is a named location in a memory
where a program can manipulate the data.
This location is used to hold the value of the
variable.
• The value of the C variable may get change in
the program.
• C variable might be belonging to any of the
data type like int, float, char etc.
35. Rules for naming C variable:
• Variable name must begin with letter or
underscore.
• Variables are case sensitive
• They can be constructed with digits, letters.
• No special symbols are allowed other than
underscore.
• average, height, age, total are some examples
for variable name
36. Operators in C
Operators are the foundation of any
programming language. Thus the functionality
of C programming language is incomplete
without the use of operators. We can define
operators as symbols that help us to perform
specific mathematical and logical
computations on operands. In other words,
we can say that an operator operates the
operands
37.
38. 1.Arithmetic Operators
An arithmetic operator performs mathematical
operations such as addition, subtraction,
multiplication, division etc on numerical
values
39.
40.
41. • Output
• a+b = 13
• a-b = 5
• a*b = 36
• a/b = 2 Remainder when a divided by b=1
42. Bitwise Operator in C
• The bitwise operators are the operators used
to perform the operations on the data at the
bit-level. When we perform the bitwise
operations, then it is also known as bit-level
programming.
• It consists of two digits, either 0 or 1. It is
mainly used in numerical computations to
make the calculations faster.
43.
44.
45.
46.
47. Relational Operators
• These Operators are used to check the
relationship between the two operands. If the
relation is true, it returns 1; if the relation is
false, it returns value 0. Relational operators
are used in decision making and loops.
48.
49.
50.
51. 3.logical operators
• A logical operator is a symbol or word used to
connect two or more expressions such that
the value of the compound expression
produced depends only on that of the original
expressions and on the meaning of the
operator. Common logical operators include
AND, OR, and NOT.
54. Assignment Operators
• Assignment operators are used when the
value is to be assigned to an identifier, a
variable. With execution of assignment
operators, value at the right is assigned to the
left. The destination variable loses the old
value; i.e. old value is over ridden with the
new value. If previous value is also required; it
should be saved in some other variables.