SlideShare a Scribd company logo
1 of 20
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

Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and commentsNilimesh Halder
 
Why C is Called Structured Programming Language
Why C is Called Structured Programming LanguageWhy C is Called Structured Programming Language
Why C is Called Structured Programming LanguageSinbad Konick
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programmingTarun Sharma
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Operators and Control Statements in Python
Operators and Control Statements in PythonOperators and Control Statements in Python
Operators and Control Statements in PythonRajeswariA8
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAkshay Ithape
 
Python functions
Python functionsPython functions
Python functionsAliyamanasa
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methodsnarmadhakin
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & ImportMohd Sajjad
 
Introduction to Computer
Introduction to ComputerIntroduction to Computer
Introduction to Computerzaheeriqbal41
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Alphabets , strings, languages and grammars
Alphabets , strings, languages  and grammarsAlphabets , strings, languages  and grammars
Alphabets , strings, languages and grammarshele987
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in pythonJothi Thilaga P
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on pythonwilliam john
 

What's hot (20)

Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Basics of python
Basics of pythonBasics of python
Basics of python
 
History of c
History of cHistory of c
History of c
 
Why C is Called Structured Programming Language
Why C is Called Structured Programming LanguageWhy C is Called Structured Programming Language
Why C is Called Structured Programming Language
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Python basics
Python basicsPython basics
Python basics
 
Operators and Control Statements in Python
Operators and Control Statements in PythonOperators and Control Statements in Python
Operators and Control Statements in Python
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Python functions
Python functionsPython functions
Python functions
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
Introduction to Computer
Introduction to ComputerIntroduction to Computer
Introduction to Computer
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Alphabets , strings, languages and grammars
Alphabets , strings, languages  and grammarsAlphabets , strings, languages  and grammars
Alphabets , strings, languages and grammars
 
Python functions
Python functionsPython functions
Python functions
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 

Viewers also liked

E-examination Engine
E-examination EngineE-examination Engine
E-examination EngineAlpana Gupta
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languageseducationfront
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek 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 - JavaTpointJavaTpoint.Com
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming languagesanjay joshi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 
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 MethodsRiant 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-XIIAtif Khan
 

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 (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
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
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(); }