SlideShare uma empresa Scribd logo
1 de 35
Vineet Sharma
Introducing of C
• C is a programming language
developed at AT & T Bell Laboratories
of USA in 1972, designed and written
by Dennis Ritchie.
• C is highly portable i.e., software
written for one computer can be run
on another computer.
• An important feature of C is its ability
to extend itself. A C program is basically
a collection of functions.
Reasons to use C
• Easy to learn & write programs.
• Structured language.
• Many common programs are written in C.
• Programs that are created with C run very quickly.
• It allows you direct control over the very low level aspects of the
computer.
• It was (and still is in some circumstances) the language of choice in
Operating System Development (including all of Unix).
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.
• Today's most popular Linux OS, Oracle and RDBMS MySQL have been written
in C.
History of C
Year Language Developed by Remarks
1960
ALGOL 60 (Algorithmic
Language)
International Committee Too general, too abstract
1963
CPL (Combined
Programming Language)
Cambridge University
Hard to learn, difficult to
implement
1967
BCPL (Basic Combined
Programming Language)
Martin Richards at Cambridge
University
Could deal with only specific
problems
1970 B Ken Thompson at AT & T Bell Labs
Could deal with only specific
problems
1972 C Dennis Ritchie in AT & T Bell Labs Structured Programing
Martin Richards Ken Thompson Dennis Ritchie Ken Thompson & Dennis Ritchie
What is Computer Programming
• A computer program is just a collection of the instructions
necessary to solve a specific problem.
• A program is a set of instruction that tell a computer what to
do.
• Computer Programming is the process of creating computer
programs.
• A program is creating using a programming language.
• A programming language is a language that can be used to
communicate with a computer.
• So for as programming language concern these are of two
types.
1) Machine Oriented (Low/Middle level language)
2) Problem Oriented (High level language)
But C is considered as a Middle level Language. C is modular,
portable, reusable.
Getting Started with C
Steps in learning English language:
Steps in learning C:
Alphabets Words Sentence Paragraphs
Alphabets, Digits &
Special Symbols
Constants, Variables &
Keywords Instructions Program
C Tokens
• A token is an atomic unit (smallest invisible units) in a
program.
• The most basic elements in a C program recognized by the
compiler are a single character or a group of characters called
C tokens.
• The compiler cannot breakdown the token any further. For
example, the words main, ‘{’ (brace), ‘(’ (parenthesis) are all
tokens of C program.
Types of tokens
1. Keywords
Example: int, float, double, char, void, while, for
2. Identifiers
Example: main, amount
3. Constants
Example: 12.4, 7894
4. Strings
Example: “Amit”, “Sunday”
5. Special Symbols
Example: [, ], {, }, (, )
6. Operators
Example: +, -, *, /, %
The C Character Set
The C character set includes the upper case letters A to Z, the
lower case a to z, the decimal digits 0 to 9 and certain special
characters.
Alphabets
Digits
Special Symbols
A, B, C,…,X, Y, Z
A, b, c,…,x,y,z
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
~ ! @ # % ^ & * ( ) _ - + = |  { } [ ] ; :
“ ‘ < > , . ?/
Special Symbols
Character/ Symbol Meaning Character/ Symbol Meaning
~ Tilde , Comma
. Period ; Semicolon
? Question mark : Colon
“ Double quote ‘ Single quote
( Left parenthesis ) Right parenthesis
[ Left bracket ] Right bracket
{ Left brace } Right brace
/ Slash  Back slash
< Less than > Greater than
= Equal to ! Exclamatory mark
- Minus + Plus
# Hash $ Dollar sign
& Ampersand * Asterisk
% Percent ^ Carat
_ Underscore | Vertical bar
Identifiers in C
• Identifiers are the name used to identify a constant, variable, function, or any other
user defined item.
• An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero
or more letters, underscores, and digits (0 to 9).
• No commas or blank space are allowed within a variable name.
• C does not allow punctuation characters such as @, $, and % within identifiers.
• C is a case-sensitive programming language. Thus, Manpower and manpower are
two different identifiers in C.
Mohd zara abc move_name a_123
Myname50 _temp j a23b9 retVal
Keywords in C
• Keywords are predefined tokens in C. These are also called reserved words.
• Keywords have special meaning to the C Compiler. These keywords can be used only
for their intended action; they cannot be used for any other purpose.
• C has 32 keywords.
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
contiune for signed void
default goto sizeof volatile
do if static while
Data Types
•A data type defines a set of values and the operations
that can be performed on them.
•Every datatype item (constant, variable etc.) in C
program has a datatype associated with it.
•C also has a special datatype called void, which,
indicates that any data type, i.e., no data type, does not
describe the data items.
Primitive Data Type
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
contiune for signed void
default goto sizeof volatile
do if static while
Primitive Data Type
Data types Description Size (No. of Bytes) Range
Char Single Character 1 0 to 255
Int An Interger 2 -32,768 to +32,767
Float Float point number 4
-2,147,483,648 to
+2,147,483,647
Double Float point number 8
Approx. 15 digits of
Precision
Void No data type 0
Signed char Character 1 -128 to 127
Unsigned char Unsigned character 1 0 to 255
Short signed int Short signed integer 2 -32,768 to +32,767
Short unsigned int
Short unsigned
interger
3 0 to 65,535
Long singned int Long signed integer 4
-2,147,483,648 to
+2,147,483,647
Constants in C
A constant is a literal, which remain unchanged during the execution of
a program.
A constant is a fixed value that cannot be altered during execution of
program.
C constants can be classified into two categories:
Primary Constants Secondary Constants
Integer Constants Array
Real Constants Pointer
Character Constants Structure
Union
Enum
Rules for Construction Integer Constants
An integer constant must have at least one digit.
It should not contain either a decimal point or exponent.
If a constant is positive, it may or not be preceded by a plus sign. If it is
a negative, it must be preceded by minus sign.
Commas, blanks and non-digit characters are not allowed in integer
constants.
The value of integer constant cannot exceed specified limits.
The valid range is
-32,768 to +32,767
Real Constants
Real values are often called floating-point constants. There are two
ways to represent a real constant decimal form and exponential form.
In exponential form of representation, the real constant is represented
in two parts. The part appearing before ‘e’ is called mantissa, whereas
the part following ‘e’ is called exponent.
Rules for Construction Real Constants
The mantissa part and the exponential part should be separate by a
letter ‘e’.
The mantissa part may have a positive or negative sign.
Default sign of mantissa part is positive.
The exponent must have at least one digit, which must be a positive or
negative integer. Default sign is positive.
Range of real constants expressed in exponential form is
-3.4e38 to 3.4e38.
Rules for Construction Character Constants
A character constant is a single alphabet, a single digit or a single
special symbol enclosed within single inverted commas. Both the
inverted commas point to the left. For example, ‘A’ is valid charcter
constant whereas A is not.
 The maximum length of a character constant can be 1 character.
Note: Every character has its ASCII (American Standard Code for
Information Interchange) value. That means every character is
interchange with integer constant. For example, ‘A’ value is 65 and ‘a’
value is 97.
String Constants
A string constant is a sequence of character enclosed in double quotes.
The character may be letter, number, blank space or special character.
Note that “” is null string or empty string. And the single string
constant is “A” is not equivalent to the single character constant ‘A’.
Each String constant must end with a special character ‘o’. This
character is called null character and used to terminate the string. The
compiler automatically places a null ‘o’ character at the end of every
string constant.
Escape sequence
Some non-printing characters and some other character such as double
quote (“), single quote (‘), question mark (?) and backslash (), required
an escape sequence. A list of commonly used backslash character
constants is given below:
Escape
Sequence
Meaning ASCII Value
Escape
Sequence
Meaning ASCII Value
a Bell 7 r Carriage return 13
b Back Space 8 ” Double quote 34
t Tab 9 ’ Single quote 39
n New line 10 ? Question mark 63
v Vertical tab 11  Back slash 92
f Form feed 12 0 Null 0
Variables in C
• A variable can be considered as a name given to the location
in memory.
• The term variable is used to denote any value that is referred
to a name instead of explicit value.
• A variable is able to hold different value during execution of a
program, where as a constant is restricted to just one value.
• For example, in the equation 2x+3y=10; since x and y can
change, they are variables, where as 2, 3 and 10 cannot
change, hence they are constants. The total equation is known
as expression.
Rules for Construction Variable Names
The name of a variable is composed of one to several characters, the
first of which must be a letter .
No special characters other than letters, digits, and underscore can be
used in variable name. Some compilers permit underscore as the first
character.
Commas or Blanks are not allowed with in a variable name.
Upper case and Lower case letters are significant. That is the variable
“income” is not same as “INCOME”.
The variable name should not be a C key word. Also it should not have
the same name as a function that is written either by user or already
exist in the C library.
C Instructions
There are basically four types of instructions in C:
Type Declaration Instruction
Input/Output Instruction
Arithmetic Instruction
Control Instruction
The purpose of each instructions
Type Declaration instruction To declare the type of variables used in
a C program
Input/Output instruction To perform the function of supplying
input data to a program and obtaining
the output results from it.
Arithmetic instruction To perform arithmetic operations
between constants and variables.
Control instruction To control the sequence of execution of
various statement in a C program.
Operations & Expressions
 An operator is a symbol that tells the computer to perform
certain mathematical or logical manipulations.
 Operators are used in program to manipulate data and
variables. The data items that operators act upon are called
operands.
 Some operators require two operands, while others act upon
only one operand. The operators are classified into unary,
binary and ternary depending on whether they operate on
one, two or three operands respectively.
Types of operators
C has four classes of operators
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bit-wise Operators
In addition, C has some special operators, which are unique to
C, they are
1. Increment & Decrement Operators
2. Conditional Operators
3. Assignment Operators, etc.
Arithmetic Operators
There are five arithmetic operators in C.
The following table lists the arithmetic operators allowed in C:
Operator Meaning
+ Addition
- Subtraction; also for unary minus
* Multiplication
/ Division
% Modulo division (remainder after integer division)
Structure of C Program
1. Documentation Section (Comment Line)
1. // Single line Comment
2. /* Multiple line Comment */
2. Link Section (Header files means Predefined Fuctions)
1. #include <stdio.h>
2. #include <conio.h>
3. #include <math.h>
4. #include <graphics.h>
Structure of C Program
3. Definition Section (Symbolic Constant)
1. #define MAX 50
4. Global Declaration Section (Global Variables)
1. PI= 3.14159,
2. A=10, B=20;
5. Main Function
1. Declaration Part (Local Variable)
2. Executable Part (Statements)
Structure of C Program
6. Sub-Program Section (User Defined Functions)
1. Function-1
2. Function-2
3. Function-3
4. Function-n
Structure of C Program
1. Comment line
2. Preprocessor directive
3. Global variable declaration
4. main function( )
{
Local variables;
Statements;
}
User defined function
{
}
First Program in C
#include<stdio.h> // standard input output header
#include<conio.h> // console input output header
main() // start of main function
{
clrscr(); // predefined function for clear screen
printf(“Hello World”); // predefined function for print
getch(); // for hold screen till user response
} // end of main function
Save the source file with extension filename.c

Mais conteúdo relacionado

Mais procurados (20)

C functions
C functionsC functions
C functions
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
String in c
String in cString in c
String in c
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Enums in c
Enums in cEnums in c
Enums in c
 
C++
C++C++
C++
 
C introduction by thooyavan
C introduction by  thooyavanC introduction by  thooyavan
C introduction by thooyavan
 
C Language
C LanguageC Language
C Language
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Constants in java
Constants in javaConstants in java
Constants in java
 
C basics
C   basicsC   basics
C basics
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 

Semelhante a Programming in c

Semelhante a Programming in c (20)

All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 
Basics of C
Basics of CBasics of C
Basics of C
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of c
Basics of cBasics of c
Basics of c
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Funa-C.ppt
Funa-C.pptFuna-C.ppt
Funa-C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
C programming basic pdf.ppt
C programming basic pdf.pptC programming basic pdf.ppt
C programming basic pdf.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.pptBasics of C--C Basics------------------.ppt
Basics of C--C Basics------------------.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 

Último (20)

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Programming in c

  • 2. Introducing of C • C is a programming language developed at AT & T Bell Laboratories of USA in 1972, designed and written by Dennis Ritchie. • C is highly portable i.e., software written for one computer can be run on another computer. • An important feature of C is its ability to extend itself. A C program is basically a collection of functions.
  • 3. Reasons to use C • Easy to learn & write programs. • Structured language. • Many common programs are written in C. • Programs that are created with C run very quickly. • It allows you direct control over the very low level aspects of the computer. • It was (and still is in some circumstances) the language of choice in Operating System Development (including all of Unix).
  • 4. 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. • Today's most popular Linux OS, Oracle and RDBMS MySQL have been written in C.
  • 5. History of C Year Language Developed by Remarks 1960 ALGOL 60 (Algorithmic Language) International Committee Too general, too abstract 1963 CPL (Combined Programming Language) Cambridge University Hard to learn, difficult to implement 1967 BCPL (Basic Combined Programming Language) Martin Richards at Cambridge University Could deal with only specific problems 1970 B Ken Thompson at AT & T Bell Labs Could deal with only specific problems 1972 C Dennis Ritchie in AT & T Bell Labs Structured Programing Martin Richards Ken Thompson Dennis Ritchie Ken Thompson & Dennis Ritchie
  • 6. What is Computer Programming • A computer program is just a collection of the instructions necessary to solve a specific problem. • A program is a set of instruction that tell a computer what to do. • Computer Programming is the process of creating computer programs. • A program is creating using a programming language. • A programming language is a language that can be used to communicate with a computer. • So for as programming language concern these are of two types. 1) Machine Oriented (Low/Middle level language) 2) Problem Oriented (High level language) But C is considered as a Middle level Language. C is modular, portable, reusable.
  • 7. Getting Started with C Steps in learning English language: Steps in learning C: Alphabets Words Sentence Paragraphs Alphabets, Digits & Special Symbols Constants, Variables & Keywords Instructions Program
  • 8. C Tokens • A token is an atomic unit (smallest invisible units) in a program. • The most basic elements in a C program recognized by the compiler are a single character or a group of characters called C tokens. • The compiler cannot breakdown the token any further. For example, the words main, ‘{’ (brace), ‘(’ (parenthesis) are all tokens of C program.
  • 9. Types of tokens 1. Keywords Example: int, float, double, char, void, while, for 2. Identifiers Example: main, amount 3. Constants Example: 12.4, 7894 4. Strings Example: “Amit”, “Sunday” 5. Special Symbols Example: [, ], {, }, (, ) 6. Operators Example: +, -, *, /, %
  • 10. The C Character Set The C character set includes the upper case letters A to Z, the lower case a to z, the decimal digits 0 to 9 and certain special characters. Alphabets Digits Special Symbols A, B, C,…,X, Y, Z A, b, c,…,x,y,z 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ~ ! @ # % ^ & * ( ) _ - + = | { } [ ] ; : “ ‘ < > , . ?/
  • 11. Special Symbols Character/ Symbol Meaning Character/ Symbol Meaning ~ Tilde , Comma . Period ; Semicolon ? Question mark : Colon “ Double quote ‘ Single quote ( Left parenthesis ) Right parenthesis [ Left bracket ] Right bracket { Left brace } Right brace / Slash Back slash < Less than > Greater than = Equal to ! Exclamatory mark - Minus + Plus # Hash $ Dollar sign & Ampersand * Asterisk % Percent ^ Carat _ Underscore | Vertical bar
  • 12. Identifiers in C • Identifiers are the name used to identify a constant, variable, function, or any other user defined item. • An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9). • No commas or blank space are allowed within a variable name. • C does not allow punctuation characters such as @, $, and % within identifiers. • C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Mohd zara abc move_name a_123 Myname50 _temp j a23b9 retVal
  • 13. Keywords in C • Keywords are predefined tokens in C. These are also called reserved words. • Keywords have special meaning to the C Compiler. These keywords can be used only for their intended action; they cannot be used for any other purpose. • C has 32 keywords. auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned contiune for signed void default goto sizeof volatile do if static while
  • 14. Data Types •A data type defines a set of values and the operations that can be performed on them. •Every datatype item (constant, variable etc.) in C program has a datatype associated with it. •C also has a special datatype called void, which, indicates that any data type, i.e., no data type, does not describe the data items.
  • 15. Primitive Data Type auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned contiune for signed void default goto sizeof volatile do if static while
  • 16. Primitive Data Type Data types Description Size (No. of Bytes) Range Char Single Character 1 0 to 255 Int An Interger 2 -32,768 to +32,767 Float Float point number 4 -2,147,483,648 to +2,147,483,647 Double Float point number 8 Approx. 15 digits of Precision Void No data type 0 Signed char Character 1 -128 to 127 Unsigned char Unsigned character 1 0 to 255 Short signed int Short signed integer 2 -32,768 to +32,767 Short unsigned int Short unsigned interger 3 0 to 65,535 Long singned int Long signed integer 4 -2,147,483,648 to +2,147,483,647
  • 17. Constants in C A constant is a literal, which remain unchanged during the execution of a program. A constant is a fixed value that cannot be altered during execution of program. C constants can be classified into two categories: Primary Constants Secondary Constants Integer Constants Array Real Constants Pointer Character Constants Structure Union Enum
  • 18. Rules for Construction Integer Constants An integer constant must have at least one digit. It should not contain either a decimal point or exponent. If a constant is positive, it may or not be preceded by a plus sign. If it is a negative, it must be preceded by minus sign. Commas, blanks and non-digit characters are not allowed in integer constants. The value of integer constant cannot exceed specified limits. The valid range is -32,768 to +32,767
  • 19. Real Constants Real values are often called floating-point constants. There are two ways to represent a real constant decimal form and exponential form. In exponential form of representation, the real constant is represented in two parts. The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.
  • 20. Rules for Construction Real Constants The mantissa part and the exponential part should be separate by a letter ‘e’. The mantissa part may have a positive or negative sign. Default sign of mantissa part is positive. The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive. Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
  • 21. Rules for Construction Character Constants A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas point to the left. For example, ‘A’ is valid charcter constant whereas A is not.  The maximum length of a character constant can be 1 character. Note: Every character has its ASCII (American Standard Code for Information Interchange) value. That means every character is interchange with integer constant. For example, ‘A’ value is 65 and ‘a’ value is 97.
  • 22. String Constants A string constant is a sequence of character enclosed in double quotes. The character may be letter, number, blank space or special character. Note that “” is null string or empty string. And the single string constant is “A” is not equivalent to the single character constant ‘A’. Each String constant must end with a special character ‘o’. This character is called null character and used to terminate the string. The compiler automatically places a null ‘o’ character at the end of every string constant.
  • 23. Escape sequence Some non-printing characters and some other character such as double quote (“), single quote (‘), question mark (?) and backslash (), required an escape sequence. A list of commonly used backslash character constants is given below: Escape Sequence Meaning ASCII Value Escape Sequence Meaning ASCII Value a Bell 7 r Carriage return 13 b Back Space 8 ” Double quote 34 t Tab 9 ’ Single quote 39 n New line 10 ? Question mark 63 v Vertical tab 11 Back slash 92 f Form feed 12 0 Null 0
  • 24. Variables in C • A variable can be considered as a name given to the location in memory. • The term variable is used to denote any value that is referred to a name instead of explicit value. • A variable is able to hold different value during execution of a program, where as a constant is restricted to just one value. • For example, in the equation 2x+3y=10; since x and y can change, they are variables, where as 2, 3 and 10 cannot change, hence they are constants. The total equation is known as expression.
  • 25. Rules for Construction Variable Names The name of a variable is composed of one to several characters, the first of which must be a letter . No special characters other than letters, digits, and underscore can be used in variable name. Some compilers permit underscore as the first character. Commas or Blanks are not allowed with in a variable name. Upper case and Lower case letters are significant. That is the variable “income” is not same as “INCOME”. The variable name should not be a C key word. Also it should not have the same name as a function that is written either by user or already exist in the C library.
  • 26. C Instructions There are basically four types of instructions in C: Type Declaration Instruction Input/Output Instruction Arithmetic Instruction Control Instruction
  • 27. The purpose of each instructions Type Declaration instruction To declare the type of variables used in a C program Input/Output instruction To perform the function of supplying input data to a program and obtaining the output results from it. Arithmetic instruction To perform arithmetic operations between constants and variables. Control instruction To control the sequence of execution of various statement in a C program.
  • 28. Operations & Expressions  An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.  Operators are used in program to manipulate data and variables. The data items that operators act upon are called operands.  Some operators require two operands, while others act upon only one operand. The operators are classified into unary, binary and ternary depending on whether they operate on one, two or three operands respectively.
  • 29. Types of operators C has four classes of operators 1. Arithmetic Operators 2. Relational Operators 3. Logical Operators 4. Bit-wise Operators In addition, C has some special operators, which are unique to C, they are 1. Increment & Decrement Operators 2. Conditional Operators 3. Assignment Operators, etc.
  • 30. Arithmetic Operators There are five arithmetic operators in C. The following table lists the arithmetic operators allowed in C: Operator Meaning + Addition - Subtraction; also for unary minus * Multiplication / Division % Modulo division (remainder after integer division)
  • 31. Structure of C Program 1. Documentation Section (Comment Line) 1. // Single line Comment 2. /* Multiple line Comment */ 2. Link Section (Header files means Predefined Fuctions) 1. #include <stdio.h> 2. #include <conio.h> 3. #include <math.h> 4. #include <graphics.h>
  • 32. Structure of C Program 3. Definition Section (Symbolic Constant) 1. #define MAX 50 4. Global Declaration Section (Global Variables) 1. PI= 3.14159, 2. A=10, B=20; 5. Main Function 1. Declaration Part (Local Variable) 2. Executable Part (Statements)
  • 33. Structure of C Program 6. Sub-Program Section (User Defined Functions) 1. Function-1 2. Function-2 3. Function-3 4. Function-n
  • 34. Structure of C Program 1. Comment line 2. Preprocessor directive 3. Global variable declaration 4. main function( ) { Local variables; Statements; } User defined function { }
  • 35. First Program in C #include<stdio.h> // standard input output header #include<conio.h> // console input output header main() // start of main function { clrscr(); // predefined function for clear screen printf(“Hello World”); // predefined function for print getch(); // for hold screen till user response } // end of main function Save the source file with extension filename.c