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

PPTX
Introduction to C# Programming
PPSX
Type conversion
PPTX
Input and Output In C Language
PPT
Functions in C++
PPTX
Functions in c++
PPTX
Storage classes in C
PDF
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Function C programming
Introduction to C# Programming
Type conversion
Input and Output In C Language
Functions in C++
Functions in c++
Storage classes in C
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
Function C programming

What's hot (20)

PPTX
PPTX
Presentation on C programming language
PPSX
Complete C programming Language Course
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
PPT
constants, variables and datatypes in C
PPTX
C Programming: Control Structure
PPT
1. over view and history of c
PPTX
Presentation on C++ Programming Language
PDF
Pointers in C
PPT
FUNCTIONS IN c++ PPT
PPT
Structures
PPTX
Introduction to c programming
PPTX
Introduction to c++
PPTX
Java loops for, while and do...while
PDF
Problem solving methodology
PPTX
Basic Input and Output
PPT
Preprocessors
PPTX
PPTX
Data Type in C Programming
PPSX
Break and continue
Presentation on C programming language
Complete C programming Language Course
C# lecture 2: Literals , Variables and Data Types in C#
constants, variables and datatypes in C
C Programming: Control Structure
1. over view and history of c
Presentation on C++ Programming Language
Pointers in C
FUNCTIONS IN c++ PPT
Structures
Introduction to c programming
Introduction to c++
Java loops for, while and do...while
Problem solving methodology
Basic Input and Output
Preprocessors
Data Type in C Programming
Break and continue
Ad

Viewers also liked (13)

PPTX
E-examination Engine
PPTX
Introduction to Programming Languages
PPSX
INTRODUCTION TO C PROGRAMMING
PPT
C PROGRAMMING
PPT
Introduction to programming with c,
PPT
C the basic concepts
PPTX
C Programming Language Tutorial for beginners - JavaTpoint
PPTX
introduction to c programming language
PPT
Basics of C programming
PPTX
List of Software Development Model and Methods
PPTX
6 basic steps of software development process
PPTX
14 Principles of HENRI FAYOL project on KFC Class-XII
PDF
Deep C
E-examination Engine
Introduction to Programming Languages
INTRODUCTION TO C PROGRAMMING
C PROGRAMMING
Introduction to programming with c,
C the basic concepts
C Programming Language Tutorial for beginners - JavaTpoint
introduction to c programming language
Basics of C programming
List of Software Development Model and Methods
6 basic steps of software development process
14 Principles of HENRI FAYOL project on KFC Class-XII
Deep C
Ad

Similar to Introduction to c programming (20)

ODP
C prog ppt
PPTX
c_pro_introduction.pptx
PDF
C programming
PPT
Introduction to C Programming
PPT
Unit 4 Foc
PPTX
C programming
DOC
Basic c
PPTX
psp-all-unit-lecture-content- all syllabus
PDF
Getting Started with C Programming: A Beginner’s Guide to Syntax, Variables, ...
PPTX
c programming session 1.pptx
PPTX
Programming in C
PPTX
cmp104 lec 8
PPT
Introduction to C
PDF
The New Yorker cartoon premium membership of the
PPT
What is turbo c and how it works
PDF
C programming day#1
PPTX
C++ programming language basic to advance level
PPTX
C_Programming_Language_tutorial__Autosaved_.pptx
C prog ppt
c_pro_introduction.pptx
C programming
Introduction to C Programming
Unit 4 Foc
C programming
Basic c
psp-all-unit-lecture-content- all syllabus
Getting Started with C Programming: A Beginner’s Guide to Syntax, Variables, ...
c programming session 1.pptx
Programming in C
cmp104 lec 8
Introduction to C
The New Yorker cartoon premium membership of the
What is turbo c and how it works
C programming day#1
C++ programming language basic to advance level
C_Programming_Language_tutorial__Autosaved_.pptx

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(); }