SlideShare a Scribd company logo
By – Richa Gupta
CONTENTS 
 What is C? 
 History 
 Why we use c 
 Basics of C environment 
 Getting started with C 
 Data types / Keywords 
 Variables / C character set 
 Operators 
 The If – else statement 
 Switch variables 
 Loops
What is c ? 
o Programming Language written by Brian Kernighan and D 
D Dennis Ritchie . 
o C has been designed to have both high level languages and 
l low level languages so it is often called middle level 
languages. 
o Highly structured language . 
o Handle bit level operation . 
o There are zillions of lines of C legacy code . 
o It is also used in application program . 
o To develop system software- compilers , operating system.
Year Language Developed by Remarks 
1960 ALGOL International 
Committee 
Too general, too 
abstract 
1963 CPL Cambridge 
University 
Hard to learn , 
difficult to 
implement 
1967 BCPL Martin Richards 
at Cambridge 
University 
Could deal with 
only specific 
problems 
1970 B Ken Thompson 
at AT & T 
Could deal with 
only specific 
problems 
1972 C Dennis Ritchie 
at AT & T 
Lost generality of 
BCPL and B 
restored 
History
Why we use c ? 
Mainly because it produces codes that runs nearly as fast as 
code written in assembly language some examples of the use of 
c might be : 
 Operating systems 
 Language compilers 
 Assemblers 
 Text editors 
 Print spoolers 
 Network drivers 
 Modern programs 
 Data bases 
 Language interpreters 
 Utilities.
Basics of C environment 
C system consist of 3 parts 
- Environment 
- Language 
- c standard library. 
Development environment has 6 phases . 
• Edit : Writing the source code by using some IDE or editor. 
• Pre-processor : Already available routine. 
• Compile : Translates or converts source to object code for a 
s specific platform i.e., source code -> object codes. 
• Link : Links object code with libraries and stores on disk. 
• Load : Puts the program in memory. 
• Execute : Runs the program.
Executing a c program . 
Computer Edit program 
source code 
Compile 
Object code 
Library files Link object code executable Computer
Getting started c program. 
#include<stdio.h> // preprocessor directive . 
#include<conio.h> 
void main() // Main function. 
{ //Start of the program. 
printf(“hello world”); // Function from C library that 
getch(); is used to print strings to the 
clrscr(); output of our screen. 
} // End of the program.
Data Types . 
1. Integer int 2 bytes 
2. Long integer long int 4 bytes 
3. Character char 1 bytes 
4. Float float 4 bytes 
5. Double double 8 bytes 
Some Keywords 
Auto double Int struct 
Break Else Long Switch 
Case Enum Register Typedef 
Char Extern Return Union 
Const Float Short Unsigned 
Continue For Signed Void 
Default Goto Size of Volatile 
do If static While
Variables 
 These names of variables consists of numbers , letters , 
and underscores. 
 The restriction on names is that you may not use 
keywords as the name of variables or functions. 
 Declarations are important in multi file programs where a 
variables defined in one file must be referred to second 
The C Character Set 
A character denotes any alphabet , digit or special 
symbol used to represent information. 
Alphabets A ,B ,……………, Y , Z 
A , b ,………….., y , z 
Digits 0 , 1 , 2, 3 , 4 , 5 , 6, 7 , 8 , 9 
Special symbols ~ ‘ ! @ # % & * ( ) _ - + = 
 | { } [ ] ; : “ ‘ < > , . ? /
Operators 
1. Arithmetic operator 
a) Binary operator 
+ , - , * , /, % 
b) Unary operator 
++ , -- , - 
++ increment by 1 
-- decrement by 1 
- negative 
2. Assignment operator 
int a = 10, b = 5 , c : 
c = a+b : 
3. Compound Assignment operator 
+=, -= , /= , %= , * = 
4. Comparison operator 
>,< ,>= ,<= , != , ==
5. Logical operator 
&& (And) , || (or) , ! (not). 
&& (And) 
Cond 1 Cond 2 Result 
T T T 
T F F 
F T F 
F F F 
All condition true the true otherwise false . 
|| (or) 
Cond 1 Cond 2 Result 
T T T 
T F T 
F T T 
F F F 
All conditions false result false otherwise true .
! (Not) 
Cond 1 Result 
T F 
F T 
• Prefix Increment value than use ++a. 
• Postfix Use value than increment a++. 
 Write a program to add two numbers. 
#include <stdio.h> 
#include<conio.h> 
void main () 
{ 
int a=10, b=5; 
printf(“a+b=%d”,a+b); 
getch(); 
clrscr(); 
}
The If – else statement 
if (condition) if (condition) 
{ 
Statement 1; statement- sequence 1; 
else } 
Statement2; else 
{ 
statement - sequence 2; 
}
 Write a program to check given no. is even or 
odd. 
#include <stdio.h> 
#include<conio.h> 
void main () 
{ 
int num; 
printf(“enter a number”); 
scanf(“%d”, & num); 
if (num%2 ==0) 
printf(“even number”); 
else 
printf(“odd number”); 
getch(); 
clrscr(); 
}
Switch variables 
{ 
case value; 
case value; 
} 
 Write a program to show the given character is vowel or constant . 
#include<stdio.h> 
#include<conio.h> 
void main () 
{ 
char c; 
printf(“enter character :”); 
scanf(“%c” & c); 
switch (c) 
{ 
case ‘a’ 
case ‘e’ 
case ‘i’ 
case ‘o’ 
case ‘u‘ 
printf (“vowel”); 
break; 
default 
printf (“const”); 
} 
getch(); 
clrscr(); 
}
Loops 
A loop is a sequence of statements which is specified once but 
which may be carried out several times in succession. 
There are three methods by way of which we can repeat a part of a 
program. They are : 
a. Using a for statement 
b. Using a while statement 
c. Using a do- while statement
Write a program to implement for loop. 
#include<stdio.h> 
#include<conio.h> 
Void main(); 
{ 
int c; 
for (c=1;c<=5;c++); 
{ 
printf(“n%d”,c); 
} 
getch(); 
Clrscr(); 
} 
for loop 
for (initialization;condition;increament) 
{ 
statement 
}
While loop 
While (condition) 
{ 
statement; 
increment; 
} 
 Write a program to implement while loop. 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int c =1; 
while (c<=5) 
{ 
printf(“n%d”,c); 
c++; 
} 
getch(); 
clrscr(); 
}
Do While 
do 
{ 
statement; 
increment 
} 
while (condition); 
 Write a program to implement do while loop. 
#include <stdio.h> 
#include<conio.h> 
void main() 
{ 
int sum =0, num; 
do 
{ 
printf (“enter a number n”) 
scanf (“%d”,& num); 
sum += num; 
} 
while (num!=0); 
printf (“sum=%d”,sum); 
getch(); 
clrscr(); 
}

More Related Content

What's hot

fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
Vijayalaxmi Wakode
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
ppd1961
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Conditional operators
Conditional operatorsConditional operators
Conditional operators
BU
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
Mohamed Loey
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
Tarun Sharma
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by Balaguruswami
Priya Chauhan
 
C functions
C functionsC functions
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage classkapil078
 
History of c
History of cHistory of c
History of c
Shipat Bhuiya
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
Rai University
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 

What's hot (20)

fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Conditional operators
Conditional operatorsConditional operators
Conditional operators
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by Balaguruswami
 
C functions
C functionsC functions
C functions
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
History of c
History of cHistory of c
History of c
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
Loops c++
Loops c++Loops c++
Loops c++
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Function in c program
Function in c programFunction in c program
Function in c program
 
C notes
C notesC notes
C notes
 

Viewers also liked

E-examination Engine
E-examination EngineE-examination Engine
E-examination Engine
Alpana Gupta
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
educationfront
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of cHarish Kumawat
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
Hossain Md Shakhawat
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming language
sanjay joshi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
List of Software Development Model and Methods
List of Software Development Model and MethodsList of Software Development Model and Methods
List of Software Development Model and Methods
Riant Soft
 
6 basic steps of software development process
6 basic steps of software development process6 basic steps of software development process
6 basic steps of software development processRiant Soft
 
14 Principles of HENRI FAYOL project on KFC Class-XII
14 Principles of HENRI FAYOL  project on KFC Class-XII14 Principles of HENRI FAYOL  project on KFC Class-XII
14 Principles of HENRI FAYOL project on KFC Class-XII
Atif Khan
 
Deep C
Deep CDeep C
Deep C
Olve Maudal
 

Viewers also liked (14)

E-examination Engine
E-examination EngineE-examination Engine
E-examination Engine
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming language
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
List of Software Development Model and Methods
List of Software Development Model and MethodsList of Software Development Model and Methods
List of Software Development Model and Methods
 
6 basic steps of software development process
6 basic steps of software development process6 basic steps of software development process
6 basic steps of software development process
 
14 Principles of HENRI FAYOL project on KFC Class-XII
14 Principles of HENRI FAYOL  project on KFC Class-XII14 Principles of HENRI FAYOL  project on KFC Class-XII
14 Principles of HENRI FAYOL project on KFC Class-XII
 
Deep C
Deep CDeep C
Deep C
 

Similar to Introduction to c programming

C prog ppt
C prog pptC prog ppt
C prog ppt
xinoe
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
RohitRaj744272
 
C programming
C programmingC programming
C programming
C programmingC programming
C programming
Rounak Samdadia
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
C programming
C programmingC programming
C programming
PralhadKhanal1
 
Basic c
Basic cBasic c
Basic c
Veera Karthi
 
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
RSathyaPriyaCSEKIOT
 
Programming in C
Programming in CProgramming in C
Programming in C
Nishant Munjal
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8kapil078
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
Janani Satheshkumar
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
Mark John Lado, MIT
 
C programming day#1
C programming day#1C programming day#1
C programming day#1
Mohamed Fawzy
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
sajjad ali khan
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
Likhil181
 
Basics of C porgramming
Basics of C porgrammingBasics of C porgramming
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
Syed Zaid Irshad
 

Similar to Introduction to c programming (20)

C prog ppt
C prog pptC prog ppt
C prog ppt
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 
C programming
C programmingC programming
C programming
 
C programming
C programmingC programming
C programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C programming
C programmingC programming
C programming
 
Basic c
Basic cBasic c
Basic c
 
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
 
Programming in C
Programming in CProgramming in C
Programming in C
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
 
C programming day#1
C programming day#1C programming day#1
C programming day#1
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
Unit4
Unit4Unit4
Unit4
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Basics of C porgramming
Basics of C porgrammingBasics of C porgramming
Basics of C porgramming
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 

Introduction to c programming

  • 1. By – Richa Gupta
  • 2. CONTENTS  What is C?  History  Why we use c  Basics of C environment  Getting started with C  Data types / Keywords  Variables / C character set  Operators  The If – else statement  Switch variables  Loops
  • 3. What is c ? o Programming Language written by Brian Kernighan and D D Dennis Ritchie . o C has been designed to have both high level languages and l low level languages so it is often called middle level languages. o Highly structured language . o Handle bit level operation . o There are zillions of lines of C legacy code . o It is also used in application program . o To develop system software- compilers , operating system.
  • 4. Year Language Developed by Remarks 1960 ALGOL International Committee Too general, too abstract 1963 CPL Cambridge University Hard to learn , difficult to implement 1967 BCPL Martin Richards at Cambridge University Could deal with only specific problems 1970 B Ken Thompson at AT & T Could deal with only specific problems 1972 C Dennis Ritchie at AT & T Lost generality of BCPL and B restored History
  • 5. Why we use c ? Mainly because it produces codes that runs nearly as fast as code written in assembly language some examples of the use of c might be :  Operating systems  Language compilers  Assemblers  Text editors  Print spoolers  Network drivers  Modern programs  Data bases  Language interpreters  Utilities.
  • 6. Basics of C environment C system consist of 3 parts - Environment - Language - c standard library. Development environment has 6 phases . • Edit : Writing the source code by using some IDE or editor. • Pre-processor : Already available routine. • Compile : Translates or converts source to object code for a s specific platform i.e., source code -> object codes. • Link : Links object code with libraries and stores on disk. • Load : Puts the program in memory. • Execute : Runs the program.
  • 7. Executing a c program . Computer Edit program source code Compile Object code Library files Link object code executable Computer
  • 8. Getting started c program. #include<stdio.h> // preprocessor directive . #include<conio.h> void main() // Main function. { //Start of the program. printf(“hello world”); // Function from C library that getch(); is used to print strings to the clrscr(); output of our screen. } // End of the program.
  • 9. Data Types . 1. Integer int 2 bytes 2. Long integer long int 4 bytes 3. Character char 1 bytes 4. Float float 4 bytes 5. Double double 8 bytes Some Keywords Auto double Int struct Break Else Long Switch Case Enum Register Typedef Char Extern Return Union Const Float Short Unsigned Continue For Signed Void Default Goto Size of Volatile do If static While
  • 10. Variables  These names of variables consists of numbers , letters , and underscores.  The restriction on names is that you may not use keywords as the name of variables or functions.  Declarations are important in multi file programs where a variables defined in one file must be referred to second The C Character Set A character denotes any alphabet , digit or special symbol used to represent information. Alphabets A ,B ,……………, Y , Z A , b ,………….., y , z Digits 0 , 1 , 2, 3 , 4 , 5 , 6, 7 , 8 , 9 Special symbols ~ ‘ ! @ # % & * ( ) _ - + = | { } [ ] ; : “ ‘ < > , . ? /
  • 11. Operators 1. Arithmetic operator a) Binary operator + , - , * , /, % b) Unary operator ++ , -- , - ++ increment by 1 -- decrement by 1 - negative 2. Assignment operator int a = 10, b = 5 , c : c = a+b : 3. Compound Assignment operator +=, -= , /= , %= , * = 4. Comparison operator >,< ,>= ,<= , != , ==
  • 12. 5. Logical operator && (And) , || (or) , ! (not). && (And) Cond 1 Cond 2 Result T T T T F F F T F F F F All condition true the true otherwise false . || (or) Cond 1 Cond 2 Result T T T T F T F T T F F F All conditions false result false otherwise true .
  • 13. ! (Not) Cond 1 Result T F F T • Prefix Increment value than use ++a. • Postfix Use value than increment a++.  Write a program to add two numbers. #include <stdio.h> #include<conio.h> void main () { int a=10, b=5; printf(“a+b=%d”,a+b); getch(); clrscr(); }
  • 14. The If – else statement if (condition) if (condition) { Statement 1; statement- sequence 1; else } Statement2; else { statement - sequence 2; }
  • 15.  Write a program to check given no. is even or odd. #include <stdio.h> #include<conio.h> void main () { int num; printf(“enter a number”); scanf(“%d”, & num); if (num%2 ==0) printf(“even number”); else printf(“odd number”); getch(); clrscr(); }
  • 16. Switch variables { case value; case value; }  Write a program to show the given character is vowel or constant . #include<stdio.h> #include<conio.h> void main () { char c; printf(“enter character :”); scanf(“%c” & c); switch (c) { case ‘a’ case ‘e’ case ‘i’ case ‘o’ case ‘u‘ printf (“vowel”); break; default printf (“const”); } getch(); clrscr(); }
  • 17. Loops A loop is a sequence of statements which is specified once but which may be carried out several times in succession. There are three methods by way of which we can repeat a part of a program. They are : a. Using a for statement b. Using a while statement c. Using a do- while statement
  • 18. Write a program to implement for loop. #include<stdio.h> #include<conio.h> Void main(); { int c; for (c=1;c<=5;c++); { printf(“n%d”,c); } getch(); Clrscr(); } for loop for (initialization;condition;increament) { statement }
  • 19. While loop While (condition) { statement; increment; }  Write a program to implement while loop. #include<stdio.h> #include<conio.h> void main() { int c =1; while (c<=5) { printf(“n%d”,c); c++; } getch(); clrscr(); }
  • 20. Do While do { statement; increment } while (condition);  Write a program to implement do while loop. #include <stdio.h> #include<conio.h> void main() { int sum =0, num; do { printf (“enter a number n”) scanf (“%d”,& num); sum += num; } while (num!=0); printf (“sum=%d”,sum); getch(); clrscr(); }