SlideShare a Scribd company logo
Introduction to c programming
 Program is a collection of instructions that
will perform some task.
 Source code of a Hello World
program written in the C programming
language
#include <stdio.h>
int main(void)
{
printf("Hello world!n");
return 0;
}
 C was developed by Dennis Ritchie at Bell
laboratory in 1972
 It is an upgraded version of languages B and
BCPL.
 It is a structured programming language.
 It is highly portable.
 It is a middle level language.
 It is a case sensitive language.
 It uses Top-Down approach.
 It is a Free form language.etc,.
GLOBAL DECLARATION SECTION
DOCUMENTATION SECTION
PREPROCESSOR SECTION
DEFINITION SECTION
main()
{
Declaration part;
Executable Part;
}
sub program section
{
Body of the subprogram;
}
 Enter the program in a C editor.
 Save the program (File  Save) or F2. Use
the extension .c for saving the file.
Eg: sample.c
 Compile the program(Compile  Compile)
or Alt+F9.
 Run the program(Run  Run) or Ctrl+F9.
 Enter the program in vi editor.
 Save the file using :wq
Use the extension .c for saving the file.
Eg: sample.c
 Compile the program.
Eg: cc sample.c (or) gcc sample.c
 Run the program using a.out.
 Identifiers are names given to various
program elements such as functions and
arrays etc,.
› Example:
int total,marks;
› Here total and marks are user defined
identifiers.
 First character must be alphabetic or underscore.
 Must consist only of alphabetic characters, digits, or
underscores.
 Only the first 31 characters of an identifier are
significant and are recognized by the compiler.
 Cannot use a keywords or reserved word (e.g. main,
include, printf & scanf etc.).
 No space are allowed between the identifiers etc,.
 C is case sensitive, e.g. My_name  my_name.
Valid Names Invalid Names
a a1 $sum /* $ is illegal */
student_name stdntNm 2names /* Starts with 2 */
_aSystemName _anthrSysNm stdnt Nmbr /* no spaces */
TRUE FALSE int /* reserved word */
Variables :
Variable is an identifier that is used to represent some
specified type of information.
Eg: x=3 Here x is variable.
auto register continue
double typedef for
int char signed
struct extern void
break return default
else union goto
long const sizeof
switch float do
case short if
enum unsigned
static while
It is a reserved word, which cannot be used for
anything else. Examples:
Constants
Character Constants
Numeric Constants
Real
Constant
Integer
Constant
String
Constant
Single
Character
Constant
Constants
Numeric Constants
Integer
Constant
Constants
Numeric Constants
Real
Constant
Integer
Constant
Constants
Numeric Constants
Single
Character
Constant
Real
Constant
Integer
Constant
Constants
Numeric Constants
String
Constant
Single
Character
Constant
Real
Constant
Integer
Constant
Constants
Numeric Constants
Constants
Numeric Constants Character Constants
Numeric Constants
It is an entity whose value does not changes during
the execution.
Integer constants
 It is formed using a sequence of digits.
Decimal - 0 to 9 .
Octal - 0 to 7.
Hexa - 0 to 9 ,A to F
Eg: 10,75 etc.
Rules for defining Integer Constant:
 It must have at least one digit.
 Decimal point are not allowed.
 No blank space or commas are allowed.
 It can be either positive or negative. Etc,.
Real constants
 It is formed using a sequence of digits but it
contain decimal point.
 length, height, price distance measured in
real number.
Eg: 2.5, 5.11, etc.
Single character constant
A character constant is a single character they
also represented with single digit or a single
special symbol which is enclosed in single quotes.
Eg: ‘a’, ‘8’,’_’etc.
String constants
 String constant are sequence of characters
enclosed with in double quote.
Eg: “Hello” ,”444”,”a” etc,.
Data Types
A data type is a classification identifying one of various
types of data, such as real-valued, integer or Boolean,
that determines the possible values for that type
 A number without a fraction part : integral number.
 Integer occupies 2 Bytes.
 The Control or Format String for integer is %d.
 C supports three different sizes of the integer
data type :
 short int
 int
 long int
 A floating-point type is a number with a
fractional part, e.g. 56.78.
 Floating point numbers occupies 4 Bytes.
 The Control or Format String for float is %f.
 C supports three different sizes of the float data
type
 Double
 float
 long double
 Character are generally stored using 8 bits(1 Byte)
of the internal storage.
 The Control or Format String for Character is %c.
Character ASCII code value
a 97(decimal) or 01100001(binary)
x 120(decimal) or 01111000(binary)
 The void type has no values and no operations.
 Both the set of values and the set of operations
are empty.
Data type Size(bytes) Range Format string
(or)Control String
Char 1 128 to 127 %c
Unsigned char 1 0 to 255 %c
Short or int 2 -32,768 to 32,767 %i or %d
Unsigned int 2 0 to 65535 %u
Long 4 -2147483648 to 2147483647 %ld
Unsigned long 4 0 to 4294967295 %lu
Float 4 3.4 e-38 to 3.4 e+38 %f or %g
Double 8 1.7 e-308 to 1.7 e+308 %lf
Long Double 10 3.4 e-4932 to 1.1 e+4932 %lf
 To create a variable, you must specify
the type.
Example: float price;
int a,b;
char code;

More Related Content

PPTX
Strings
PPTX
Managing I/O & String function in C
PPTX
PPTX
C programming - String
PPT
Operation on string presentation
PPTX
Implementation Of String Functions In C
Strings
Managing I/O & String function in C
C programming - String
Operation on string presentation
Implementation Of String Functions In C

What's hot (20)

PPT
Strings
PPTX
Strings in C
PPTX
C Programming Unit-3
PDF
Strings in c language
PDF
Strings in c mrs.sowmya jyothi
PDF
Strings IN C
PPT
String & its application
PDF
Character Array and String
PPTX
Handling of character strings C programming
PPTX
Strings in c++
PPTX
String in c programming
PPTX
Unit 8. Pointers
DOC
Assignment c programming
PPT
strings
PPTX
Lecture 2. mte 407
PPT
PDF
C Programming Assignment
PDF
String notes
PDF
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
PDF
05 c++-strings
Strings
Strings in C
C Programming Unit-3
Strings in c language
Strings in c mrs.sowmya jyothi
Strings IN C
String & its application
Character Array and String
Handling of character strings C programming
Strings in c++
String in c programming
Unit 8. Pointers
Assignment c programming
strings
Lecture 2. mte 407
C Programming Assignment
String notes
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
05 c++-strings
Ad

Similar to Introduction to c programming (20)

PPT
Introduction to C Programming
PPT
Unit 4 Foc
DOCX
fds unit1.docx
PPTX
C_Programming_Language_tutorial__Autosaved_.pptx
PPTX
Fundamentals of Programming Constructs.pptx
PPT
Introduction to C
PPTX
LESSON1-C_programming (1).GRADE 8 LESSONpptx
PPT
CPLUSPLUS UET PESHAWAR BS ELECTRICAL 2ND SEMSTER Lecture02.ppt
PDF
C Programming Language Introduction and C Tokens.pdf
PPTX
Lesson 4 Basic Programming Constructs.pptx
PPTX
Btech i pic u-2 datatypes and variables in c language
PPTX
2. introduction of a c program
PPTX
datatypes and variables in c language
PPTX
Mca i pic u-2 datatypes and variables in c language
PPTX
basic C PROGRAMMING for first years .pptx
PDF
Basic Information About C language PDF
PPTX
Diploma ii cfpc u-2 datatypes and variables in c language
DOC
1. introduction to computer
PDF
introduction to programming using ANSI C
PPTX
presentation_c_basics_1589366177_381682.pptx
Introduction to C Programming
Unit 4 Foc
fds unit1.docx
C_Programming_Language_tutorial__Autosaved_.pptx
Fundamentals of Programming Constructs.pptx
Introduction to C
LESSON1-C_programming (1).GRADE 8 LESSONpptx
CPLUSPLUS UET PESHAWAR BS ELECTRICAL 2ND SEMSTER Lecture02.ppt
C Programming Language Introduction and C Tokens.pdf
Lesson 4 Basic Programming Constructs.pptx
Btech i pic u-2 datatypes and variables in c language
2. introduction of a c program
datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
basic C PROGRAMMING for first years .pptx
Basic Information About C language PDF
Diploma ii cfpc u-2 datatypes and variables in c language
1. introduction to computer
introduction to programming using ANSI C
presentation_c_basics_1589366177_381682.pptx
Ad

Recently uploaded (20)

PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Artificial Intelligence
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
web development for engineering and engineering
PPTX
Sustainable Sites - Green Building Construction
PPTX
Geodesy 1.pptx...............................................
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Well-logging-methods_new................
Safety Seminar civil to be ensured for safe working.
Fundamentals of safety and accident prevention -final (1).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Artificial Intelligence
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
bas. eng. economics group 4 presentation 1.pptx
web development for engineering and engineering
Sustainable Sites - Green Building Construction
Geodesy 1.pptx...............................................
Automation-in-Manufacturing-Chapter-Introduction.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
III.4.1.2_The_Space_Environment.p pdffdf
Well-logging-methods_new................

Introduction to c programming

  • 2.  Program is a collection of instructions that will perform some task.  Source code of a Hello World program written in the C programming language #include <stdio.h> int main(void) { printf("Hello world!n"); return 0; }
  • 3.  C was developed by Dennis Ritchie at Bell laboratory in 1972  It is an upgraded version of languages B and BCPL.
  • 4.  It is a structured programming language.  It is highly portable.  It is a middle level language.  It is a case sensitive language.  It uses Top-Down approach.  It is a Free form language.etc,.
  • 5. GLOBAL DECLARATION SECTION DOCUMENTATION SECTION PREPROCESSOR SECTION DEFINITION SECTION main() { Declaration part; Executable Part; } sub program section { Body of the subprogram; }
  • 6.  Enter the program in a C editor.  Save the program (File  Save) or F2. Use the extension .c for saving the file. Eg: sample.c  Compile the program(Compile  Compile) or Alt+F9.  Run the program(Run  Run) or Ctrl+F9.
  • 7.  Enter the program in vi editor.  Save the file using :wq Use the extension .c for saving the file. Eg: sample.c  Compile the program. Eg: cc sample.c (or) gcc sample.c  Run the program using a.out.
  • 8.  Identifiers are names given to various program elements such as functions and arrays etc,. › Example: int total,marks; › Here total and marks are user defined identifiers.
  • 9.  First character must be alphabetic or underscore.  Must consist only of alphabetic characters, digits, or underscores.  Only the first 31 characters of an identifier are significant and are recognized by the compiler.  Cannot use a keywords or reserved word (e.g. main, include, printf & scanf etc.).  No space are allowed between the identifiers etc,.  C is case sensitive, e.g. My_name  my_name.
  • 10. Valid Names Invalid Names a a1 $sum /* $ is illegal */ student_name stdntNm 2names /* Starts with 2 */ _aSystemName _anthrSysNm stdnt Nmbr /* no spaces */ TRUE FALSE int /* reserved word */ Variables : Variable is an identifier that is used to represent some specified type of information. Eg: x=3 Here x is variable.
  • 11. auto register continue double typedef for int char signed struct extern void break return default else union goto long const sizeof switch float do case short if enum unsigned static while It is a reserved word, which cannot be used for anything else. Examples:
  • 12. Constants Character Constants Numeric Constants Real Constant Integer Constant String Constant Single Character Constant Constants Numeric Constants Integer Constant Constants Numeric Constants Real Constant Integer Constant Constants Numeric Constants Single Character Constant Real Constant Integer Constant Constants Numeric Constants String Constant Single Character Constant Real Constant Integer Constant Constants Numeric Constants Constants Numeric Constants Character Constants Numeric Constants It is an entity whose value does not changes during the execution.
  • 13. Integer constants  It is formed using a sequence of digits. Decimal - 0 to 9 . Octal - 0 to 7. Hexa - 0 to 9 ,A to F Eg: 10,75 etc. Rules for defining Integer Constant:  It must have at least one digit.  Decimal point are not allowed.  No blank space or commas are allowed.  It can be either positive or negative. Etc,.
  • 14. Real constants  It is formed using a sequence of digits but it contain decimal point.  length, height, price distance measured in real number. Eg: 2.5, 5.11, etc.
  • 15. Single character constant A character constant is a single character they also represented with single digit or a single special symbol which is enclosed in single quotes. Eg: ‘a’, ‘8’,’_’etc. String constants  String constant are sequence of characters enclosed with in double quote. Eg: “Hello” ,”444”,”a” etc,.
  • 16. Data Types A data type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type
  • 17.  A number without a fraction part : integral number.  Integer occupies 2 Bytes.  The Control or Format String for integer is %d.  C supports three different sizes of the integer data type :  short int  int  long int
  • 18.  A floating-point type is a number with a fractional part, e.g. 56.78.  Floating point numbers occupies 4 Bytes.  The Control or Format String for float is %f.  C supports three different sizes of the float data type  Double  float  long double
  • 19.  Character are generally stored using 8 bits(1 Byte) of the internal storage.  The Control or Format String for Character is %c. Character ASCII code value a 97(decimal) or 01100001(binary) x 120(decimal) or 01111000(binary)
  • 20.  The void type has no values and no operations.  Both the set of values and the set of operations are empty.
  • 21. Data type Size(bytes) Range Format string (or)Control String Char 1 128 to 127 %c Unsigned char 1 0 to 255 %c Short or int 2 -32,768 to 32,767 %i or %d Unsigned int 2 0 to 65535 %u Long 4 -2147483648 to 2147483647 %ld Unsigned long 4 0 to 4294967295 %lu Float 4 3.4 e-38 to 3.4 e+38 %f or %g Double 8 1.7 e-308 to 1.7 e+308 %lf Long Double 10 3.4 e-4932 to 1.1 e+4932 %lf
  • 22.  To create a variable, you must specify the type. Example: float price; int a,b; char code;