SlideShare a Scribd company logo
Programming With C
Fundamentals of ‘C’ including
data types, operators and I/O
statements
Gagan Deep
Founder & Director
Rozy Computech Services
Kurukshetra-136119
M- 9416011599
Email – rozygag@yahoo.com
www.rozyph.com
Contents of Discussion
• Language & Programming Language
• About C
• Character Set, Identifiers & Statements
• Data Types
• Operators
• Input Output Functions
• Programming Examples
Language
• Language is a way of Communication Between
Two like Hindi, English, Punjabi, Marathi,
Tamil etc.
• If we want to communicate other then our own
languages then we can communicate in either of
two ways
- Either Learn
- Use Translator
Programming Language
• Way of Communication between Human and
Computer like Machine language, Assembly
Language, High Level Language.
• Machine Language and Assembly Languages are
low level languages because these don’t work like
our own languages.
• High level languages(HLL) works like our own
languages like Hindi, English and others that’s
why these are known as HLL.
About C
• C is a Programming Language
• C Language is a High Level Language (because it
works like natural language). Here we uses
English like statements.
• C Language also have a properties of low level
languages
• That’s why some of us says – This is Middle
Level Language.
About C
• C is a general purpose programming language.
• C was originally designed for and implemented
on the UNIX operating system on the DEC PDP-
11, by Dennis Ritchie.
• C is a case sensitive language A≠ a
Character Set / Alphabets
• First Thing we learned in any language is
Alphabets – Similarly in Programming Languages
is Character Set.
• C character Set includes alphabets like a-z, A-Z,
Digits like 0-9, special symbols like !, @, #, $, %,
…….-, + etc., and some other characters which
are not available on keyboard <=, >=, !=, == etc.
• Print Characters- which are known as Escape
sequences like ‘n’, ‘t’, ‘b’ etc…
Words
• Second thing we always learn in any language are
words. Similarly we learn here in C. Here we say
words as Identifiers and Reserve words.
• Identifier Gagan, Rajesh, Saminder, Meenu, etc.
are our names which identifies us, and some other
names are like Table, chair, Fan, Tube which we
always we are using for some objects.
• First Type of Identifiers are known as Variable in
any Language or we can say in C and second type of
names are known as Constants.
• Some other words are known as Standard words
like min, max etc.
Rules for Naming Identifiers
• First Character is Letter not digit
• Second character it may be letter or digit
• Special characters (other then letters or digits)
are not allowed Except underscore(_)
• Length of Identifiers 8, 31 etc.
Type of Identifiers – Data Type
• Like we have our Gender Males / Females. Similarly
in each language we have some types of identifier
known as Data types.
• What data type does is categorize data.
• These basic categorizations or data types are
integer(int),
• Real(float),
• Character (char)
• char – 1 byte - -128 to 127
• Character can declare as
char c;
• int – 2 bytes - Range (-32768 to 32767)
• Integer can declare as
int a;
• float – 4 bytes - 3.4X10-38 to 3.4X1038
• Real can declare as
float f;
Why int’s range is -32768 to 32767 ?
Integer Representation
• Most of the computers use 2 bytes to store an
integer.
• The left most bit, out of sixteen bits, is used to
indicate the sign of the integer and is called Sign
bit.
• The other 15 bits are used to store the given
integer, a 0 in the sign bit position indicates a
positive integer and 1 in this position means the
integer stored is negative.
Integer Representation
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0/1
Sign
Bit
15 bits for Number representation
Maximum Number
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+215-1 = 32767
Minimum Number
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-215 = -32768
Unsigned Numbers are numbers without sign i.e. First bit is used for number itself.
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Range is 0 to 216 -1 i.e. 0 to 65535
If we want bigger number then the
ranges defined.
• char – strings
String is collection of character
• int – short, long, unsigned, unsigned long
Short is of 1 byte.
Long is of 4 bytes(double precession(size))
• float - double
Double is of 8 Bytes
Constants
• int – Decimal, Octal, Hexadecimal
• Decimal int – 77 equals 77
• Octal int – 077 equals 63
• Hexadecimal int – 0x77 equals 119
• Unsigned int – 45678U
• Unsigned long – 243567849UL
• Float –
• Char - ‘a’
• String – “Rozy” ,
Sentences / Statements
• Third thing we learn in any language are sentences,
here in programming these are known as statements.
• Statements are the instructions given to the
computer to perform any kind of action.
• Statements form the smallest executable unit within
a C++ program.
• As sentences terminated by some full stop(., I),
similarly, Statements are terminated with a
semicolon (;).
Types of Statements
• Simple Statements
• Compound Statements
• Control Statements
Simple Statement – Single statement. The
simplest statement is the empty, or null statement.
e.g.
; // it is a null statement.
Examples of simple statement are as
x=y; x=x+y; scanf(“%d”, &ajay);
printf(“%d”, ajay);
• Compound Statement – paragraph (Block) A
compound statement in C++ is a sequence of
statements enclosed by a pair of braces ({}). e.g.,
{ statement 1;
statement 2; },
A compound statement is treated as a single unit or
statement.
• Control Statements – which controls flow of
statements like decision/ branching and loops
Operators
• Operators are tokens that trigger some computation
when applied to variable and other objects in an
expression. Classifications of Operators are
Depending upon the number of operands we have :
• Unary operators : These operators require just 1
operand. e.g, - (minus sign), ++, --, sizeof etc.
• Binary operators: These operators take 2
operands. e.g. +, -, *, / , <, >, !=, <=
• Ternary operators: These operators take 3 operands,
e.g. Conditional operator (? : ) e.g. (A >B?5:6)
Operators by Operations
• Arithmetic Operators : Integer and Real
Integer : +,-, *, /, %
Real : +, -, *, /
• Relational Operators : <, >, <=, >=,
• Equality Operators : !=, ==
• Logical Operators : && (AND), ||(OR), !(NOT)
• Assignment Arithmetic Operators : +=, *=, /= etc.
e.g. a+=5 is equivalent to a=a+5. These are also
known as Compound Assignment or
Shorthand's
Operators by Operations
• Increment Operator
• Decrement Operators : Similarly pre and post
decrement operators e.g. - -a; and a- -;
Pre increment : ++a
++a means a = a +1
Pre means before execution of
statement e.g. If a=5;
Post increment : a++
a++ means a = a +1
Post means after execution of
statement e.g. If a=5;
printf(“%d”, a); //returns 5
printf(“%d”, ++a); //returns 6
printf(“%d”, a); //returns 6
printf(“%d”, a); //returns 5
printf(“%d”, a++); //returns 5
printf(“%d”, a); //returns 6
Hierarchy / Precedence of
Operators with their Associativity
Operators Category Operators Associativity
Unary Operators -, ++, - - , !, sizeof , (type) Right → Left (R→L)
Arithmetic * , / , %, Left → Right (L → R)
+ , -
Relational < , <=, >, >= L → R
Equality == , != L → R
Logical && L → R
|| L → R
Assignment =, +=, -=, *=, /=, %= R → L
Data Input and Output
• In C you can input/output using input and output
library function.
• Functions – User Defined and Library Function
• These I/O Library functions are getchar(), putchar(),
scanf(), printf(), gets() and puts().
• These six functions permits the transfer of information
between the computer and the standard I/O
devices(e.g. Keyboard, VDU etc.)
• An I/O fxs. Can be accessed from anywhere within the
program simply by writing the function name.
I/O Statements
• First we discuss about Single Character and
Strings I/O Functions
Single Character I/O
Functions are getchar()
and putchar ()
String I/O Functions are
gets() and puts()
char c;
Input statement like this
c = getchar();
Output statement like this
putchar( c );
char name[20];
Input statement like this
gets(name);
Output statement like this
puts(name);
scanf()
• With the help of scanf() we can enter any type of
data and mixed data. In general terms scanf()
function is written as
scanf( control string, arg1, arg2, arg3…, argn);
• Control String consists of individual groups of
characters, with one character group for each
input data item.
• Each character group must begin with a
percent(%) sign and followed by conversion
character which indicates the type of
corresponding data item.
Commonly used conversion characters for data
input are
• c for single character,
• d is for decimal integer,
• e for floating point value,
• f for floating point value,
• l is for long etc….
• The arguments are written as variables, arrays,
whose types match the corresponding character
group in the control string.
• Each variable must be preceded by an ampersand
(&).
• Array name should not begin with &.
Examples
char name[20];
int roll; float marks;
scanf(“ %s %d %f”, name, &roll, &marks);
• Formatted scanf() function
int a,b,c;
scanf(“%3d, %3d %3d”, &a, &b, &c);
In the above statement all a,b and c can take
maximum of 3 digits.
printf()
• It is similar to input function scanf(), except that
its purpose is to display data rather than to enter
it into the computer.
• Also there is no ampersand (&) symbol before
args.
printf(“ %s n %d n %f”, name, roll, marks);
Formatted printf() function
• example
int a,b,c;
printf(“%3d, %3d %3d”, a, b, c);
• In the above statement all a,b and c can display
minimum of 3 digits or spaces instead of digits.
Structure of C Program
# include < header file> // # is pre-processor
directive
#define x 5; //symbolic constant
int a, b; //global variable declaration
int fxn(); // function declaration
main()
{ int i,j,k; // local variable declaration
Input statements;
Process;
Output Statements; }
Program 1
# include < stdio.h>
main( ) // by default main function is int type
{ int a=5,b=6,c;
c=a+b;
printf(“The sum is = %d”, c);
}
Program 2
# include < stdio.h>
main( )
{
int a,b,c;
scanf(“%d, %d”, &a, &b);
c=a+b;
printf(“The sum is = %d”, c);
}
Program 3
# include < stdio.h>
void main()
/* void is data type which says function should not
return any value*/
{ int a,b;
scanf(“%d, %d”, &a, &b);
printf(“The sum is = %d”, a+b);
}
Program 4
# include < stdio.h>
#include <conio.h>
void main()
{
int a,b;
clrscr();
printf(“Please enter the value of a & b”);
scanf(“%3d, %3d”, &a, &b);
printf(“The sum is = %4d”, a+b); }
C – A Programming Language- I
Ad

More Related Content

What's hot (20)

Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
Selva Arrunaa Mathavan
 
Lexical analysis
Lexical analysisLexical analysis
Lexical analysis
Richa Sharma
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
Ahmad Idrees
 
Data type
Data typeData type
Data type
Frijo Francis
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
Iffat Anjum
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
athithanvijay
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
Token and operators
Token and operatorsToken and operators
Token and operators
Samsil Arefin
 
Introduction
IntroductionIntroduction
Introduction
Komal Pardeshi
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
Iffat Anjum
 
JavaScript – ECMAScript Basics By Satyen
JavaScript – ECMAScript Basics By SatyenJavaScript – ECMAScript Basics By Satyen
JavaScript – ECMAScript Basics By Satyen
Satyen Pandya
 
Introduction to C Programming - R.D.Sivakumar
Introduction to C Programming -  R.D.SivakumarIntroduction to C Programming -  R.D.Sivakumar
Introduction to C Programming - R.D.Sivakumar
Sivakumar R D .
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
Sireesh K
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
Akshaya Arunan
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
Ahmad Idrees
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
Iffat Anjum
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
Iffat Anjum
 
JavaScript – ECMAScript Basics By Satyen
JavaScript – ECMAScript Basics By SatyenJavaScript – ECMAScript Basics By Satyen
JavaScript – ECMAScript Basics By Satyen
Satyen Pandya
 
Introduction to C Programming - R.D.Sivakumar
Introduction to C Programming -  R.D.SivakumarIntroduction to C Programming -  R.D.Sivakumar
Introduction to C Programming - R.D.Sivakumar
Sivakumar R D .
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
Sireesh K
 

Viewers also liked (20)

Software Project Planning V
Software Project Planning VSoftware Project Planning V
Software Project Planning V
Gagan Deep
 
Software Project Planning IV
Software Project Planning IVSoftware Project Planning IV
Software Project Planning IV
Gagan Deep
 
Software Project Planning III
Software Project Planning IIISoftware Project Planning III
Software Project Planning III
Gagan Deep
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
Gagan Deep
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
Gagan Deep
 
Normalization 1
Normalization 1Normalization 1
Normalization 1
Gagan Deep
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i i
Gagan Deep
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Gagan Deep
 
SQL – A Tutorial I
SQL – A Tutorial  ISQL – A Tutorial  I
SQL – A Tutorial I
Gagan Deep
 
Information System and MIS
Information System and MISInformation System and MIS
Information System and MIS
Gagan Deep
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
Prof. Dr. K. Adisesha
 
System Analysis & Design - 2
System Analysis & Design - 2System Analysis & Design - 2
System Analysis & Design - 2
Gagan Deep
 
Number system
Number systemNumber system
Number system
Gagan Deep
 
Dbms viva questions
Dbms viva questionsDbms viva questions
Dbms viva questions
Balveer Rathore
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manual
maha tce
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
Pyadav010186
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
Parthipan Parthi
 
Software Project Planning V
Software Project Planning VSoftware Project Planning V
Software Project Planning V
Gagan Deep
 
Software Project Planning IV
Software Project Planning IVSoftware Project Planning IV
Software Project Planning IV
Gagan Deep
 
Software Project Planning III
Software Project Planning IIISoftware Project Planning III
Software Project Planning III
Gagan Deep
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
Gagan Deep
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
Gagan Deep
 
Normalization 1
Normalization 1Normalization 1
Normalization 1
Gagan Deep
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i i
Gagan Deep
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Gagan Deep
 
SQL – A Tutorial I
SQL – A Tutorial  ISQL – A Tutorial  I
SQL – A Tutorial I
Gagan Deep
 
Information System and MIS
Information System and MISInformation System and MIS
Information System and MIS
Gagan Deep
 
System Analysis & Design - 2
System Analysis & Design - 2System Analysis & Design - 2
System Analysis & Design - 2
Gagan Deep
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manual
maha tce
 
Sql queries interview questions
Sql queries interview questionsSql queries interview questions
Sql queries interview questions
Pyadav010186
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
Ad

Similar to C – A Programming Language- I (20)

2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
Aahwini Esware gowda
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
Dr.Florence Dayana
 
Chapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programmingChapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programming
z9819898203
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
YashwanthMalviya
 
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibulec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
ASIFANSARI480437
 
20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx
gokilabrindha
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
Bussines man badhrinadh
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt  BASIC WITH DEPTH CONTENTlecture-ON-C.ppt  BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
NagarathnaRajur2
 
basic of C programming (token, keywords)lecture2.ppt
basic of C programming (token, keywords)lecture2.pptbasic of C programming (token, keywords)lecture2.ppt
basic of C programming (token, keywords)lecture2.ppt
Raglandroyal1
 
lecture2.ppt...............................................
lecture2.ppt...............................................lecture2.ppt...............................................
lecture2.ppt...............................................
taywadebhagyashree2
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
Vijayalaxmi Wakode
 
Programming in c
Programming in cProgramming in c
Programming in c
vineet4523
 
Introduction to Programming Concepts Algorithm Flowchart Introduction to C...
Introduction to Programming Concepts  Algorithm  Flowchart  Introduction to C...Introduction to Programming Concepts  Algorithm  Flowchart  Introduction to C...
Introduction to Programming Concepts Algorithm Flowchart Introduction to C...
anuragsinghrajput252
 
Basics of C programming power point presentation
Basics of C programming power point presentationBasics of C programming power point presentation
Basics of C programming power point presentation
thoratgauri97
 
Basics of C.ppt,...................................
Basics of C.ppt,...................................Basics of C.ppt,...................................
Basics of C.ppt,...................................
taywadebhagyashree2
 
C programming and problem solving for real time solution
C programming and problem solving for real time solutionC programming and problem solving for real time solution
C programming and problem solving for real time solution
Chaitanya Jambotkar
 
Programming in C-To study basics of C programming Language.
Programming in C-To study basics of C programming Language.Programming in C-To study basics of C programming Language.
Programming in C-To study basics of C programming Language.
nrathinakumar12
 
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVBasics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
NagarathnaRajur2
 
Basics of C programming concept and type
Basics of C programming concept and  typeBasics of C programming concept and  type
Basics of C programming concept and type
baisakhiparida92
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
Aahwini Esware gowda
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
Dr.Florence Dayana
 
Chapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programmingChapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programming
z9819898203
 
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibulec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
lec1).pdfbjkbvvttytxtyvkuvvtryccjbvuvibu
ASIFANSARI480437
 
20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx
gokilabrindha
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt  BASIC WITH DEPTH CONTENTlecture-ON-C.ppt  BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
NagarathnaRajur2
 
basic of C programming (token, keywords)lecture2.ppt
basic of C programming (token, keywords)lecture2.pptbasic of C programming (token, keywords)lecture2.ppt
basic of C programming (token, keywords)lecture2.ppt
Raglandroyal1
 
lecture2.ppt...............................................
lecture2.ppt...............................................lecture2.ppt...............................................
lecture2.ppt...............................................
taywadebhagyashree2
 
Programming in c
Programming in cProgramming in c
Programming in c
vineet4523
 
Introduction to Programming Concepts Algorithm Flowchart Introduction to C...
Introduction to Programming Concepts  Algorithm  Flowchart  Introduction to C...Introduction to Programming Concepts  Algorithm  Flowchart  Introduction to C...
Introduction to Programming Concepts Algorithm Flowchart Introduction to C...
anuragsinghrajput252
 
Basics of C programming power point presentation
Basics of C programming power point presentationBasics of C programming power point presentation
Basics of C programming power point presentation
thoratgauri97
 
Basics of C.ppt,...................................
Basics of C.ppt,...................................Basics of C.ppt,...................................
Basics of C.ppt,...................................
taywadebhagyashree2
 
C programming and problem solving for real time solution
C programming and problem solving for real time solutionC programming and problem solving for real time solution
C programming and problem solving for real time solution
Chaitanya Jambotkar
 
Programming in C-To study basics of C programming Language.
Programming in C-To study basics of C programming Language.Programming in C-To study basics of C programming Language.
Programming in C-To study basics of C programming Language.
nrathinakumar12
 
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVBasics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
NagarathnaRajur2
 
Basics of C programming concept and type
Basics of C programming concept and  typeBasics of C programming concept and  type
Basics of C programming concept and type
baisakhiparida92
 
Ad

More from Gagan Deep (6)

Software Project Planning II
Software Project Planning IISoftware Project Planning II
Software Project Planning II
Gagan Deep
 
Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1
Gagan Deep
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
Gagan Deep
 
System Analysis & Design - I
System Analysis & Design - ISystem Analysis & Design - I
System Analysis & Design - I
Gagan Deep
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
Gagan Deep
 
Plsql overview
Plsql overviewPlsql overview
Plsql overview
Gagan Deep
 
Software Project Planning II
Software Project Planning IISoftware Project Planning II
Software Project Planning II
Gagan Deep
 
Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1
Gagan Deep
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
Gagan Deep
 
System Analysis & Design - I
System Analysis & Design - ISystem Analysis & Design - I
System Analysis & Design - I
Gagan Deep
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
Gagan Deep
 
Plsql overview
Plsql overviewPlsql overview
Plsql overview
Gagan Deep
 

Recently uploaded (20)

Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Lecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptxLecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptx
Arshad Shaikh
 
Debunking the Myths behind AI - v1, Carl Dalby
Debunking the Myths behind AI -  v1, Carl DalbyDebunking the Myths behind AI -  v1, Carl Dalby
Debunking the Myths behind AI - v1, Carl Dalby
Association for Project Management
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Lecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptxLecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptx
Arshad Shaikh
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 

C – A Programming Language- I

  • 1. Programming With C Fundamentals of ‘C’ including data types, operators and I/O statements Gagan Deep Founder & Director Rozy Computech Services Kurukshetra-136119 M- 9416011599 Email – [email protected] www.rozyph.com
  • 2. Contents of Discussion • Language & Programming Language • About C • Character Set, Identifiers & Statements • Data Types • Operators • Input Output Functions • Programming Examples
  • 3. Language • Language is a way of Communication Between Two like Hindi, English, Punjabi, Marathi, Tamil etc. • If we want to communicate other then our own languages then we can communicate in either of two ways - Either Learn - Use Translator
  • 4. Programming Language • Way of Communication between Human and Computer like Machine language, Assembly Language, High Level Language. • Machine Language and Assembly Languages are low level languages because these don’t work like our own languages. • High level languages(HLL) works like our own languages like Hindi, English and others that’s why these are known as HLL.
  • 5. About C • C is a Programming Language • C Language is a High Level Language (because it works like natural language). Here we uses English like statements. • C Language also have a properties of low level languages • That’s why some of us says – This is Middle Level Language.
  • 6. About C • C is a general purpose programming language. • C was originally designed for and implemented on the UNIX operating system on the DEC PDP- 11, by Dennis Ritchie. • C is a case sensitive language A≠ a
  • 7. Character Set / Alphabets • First Thing we learned in any language is Alphabets – Similarly in Programming Languages is Character Set. • C character Set includes alphabets like a-z, A-Z, Digits like 0-9, special symbols like !, @, #, $, %, …….-, + etc., and some other characters which are not available on keyboard <=, >=, !=, == etc. • Print Characters- which are known as Escape sequences like ‘n’, ‘t’, ‘b’ etc…
  • 8. Words • Second thing we always learn in any language are words. Similarly we learn here in C. Here we say words as Identifiers and Reserve words. • Identifier Gagan, Rajesh, Saminder, Meenu, etc. are our names which identifies us, and some other names are like Table, chair, Fan, Tube which we always we are using for some objects. • First Type of Identifiers are known as Variable in any Language or we can say in C and second type of names are known as Constants. • Some other words are known as Standard words like min, max etc.
  • 9. Rules for Naming Identifiers • First Character is Letter not digit • Second character it may be letter or digit • Special characters (other then letters or digits) are not allowed Except underscore(_) • Length of Identifiers 8, 31 etc.
  • 10. Type of Identifiers – Data Type • Like we have our Gender Males / Females. Similarly in each language we have some types of identifier known as Data types. • What data type does is categorize data. • These basic categorizations or data types are integer(int), • Real(float), • Character (char)
  • 11. • char – 1 byte - -128 to 127 • Character can declare as char c; • int – 2 bytes - Range (-32768 to 32767) • Integer can declare as int a; • float – 4 bytes - 3.4X10-38 to 3.4X1038 • Real can declare as float f;
  • 12. Why int’s range is -32768 to 32767 ? Integer Representation • Most of the computers use 2 bytes to store an integer. • The left most bit, out of sixteen bits, is used to indicate the sign of the integer and is called Sign bit. • The other 15 bits are used to store the given integer, a 0 in the sign bit position indicates a positive integer and 1 in this position means the integer stored is negative.
  • 13. Integer Representation 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0/1 Sign Bit 15 bits for Number representation Maximum Number 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +215-1 = 32767 Minimum Number 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -215 = -32768 Unsigned Numbers are numbers without sign i.e. First bit is used for number itself. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Range is 0 to 216 -1 i.e. 0 to 65535
  • 14. If we want bigger number then the ranges defined. • char – strings String is collection of character • int – short, long, unsigned, unsigned long Short is of 1 byte. Long is of 4 bytes(double precession(size)) • float - double Double is of 8 Bytes
  • 15. Constants • int – Decimal, Octal, Hexadecimal • Decimal int – 77 equals 77 • Octal int – 077 equals 63 • Hexadecimal int – 0x77 equals 119 • Unsigned int – 45678U • Unsigned long – 243567849UL • Float – • Char - ‘a’ • String – “Rozy” ,
  • 16. Sentences / Statements • Third thing we learn in any language are sentences, here in programming these are known as statements. • Statements are the instructions given to the computer to perform any kind of action. • Statements form the smallest executable unit within a C++ program. • As sentences terminated by some full stop(., I), similarly, Statements are terminated with a semicolon (;).
  • 17. Types of Statements • Simple Statements • Compound Statements • Control Statements Simple Statement – Single statement. The simplest statement is the empty, or null statement. e.g. ; // it is a null statement. Examples of simple statement are as x=y; x=x+y; scanf(“%d”, &ajay); printf(“%d”, ajay);
  • 18. • Compound Statement – paragraph (Block) A compound statement in C++ is a sequence of statements enclosed by a pair of braces ({}). e.g., { statement 1; statement 2; }, A compound statement is treated as a single unit or statement. • Control Statements – which controls flow of statements like decision/ branching and loops
  • 19. Operators • Operators are tokens that trigger some computation when applied to variable and other objects in an expression. Classifications of Operators are Depending upon the number of operands we have : • Unary operators : These operators require just 1 operand. e.g, - (minus sign), ++, --, sizeof etc. • Binary operators: These operators take 2 operands. e.g. +, -, *, / , <, >, !=, <= • Ternary operators: These operators take 3 operands, e.g. Conditional operator (? : ) e.g. (A >B?5:6)
  • 20. Operators by Operations • Arithmetic Operators : Integer and Real Integer : +,-, *, /, % Real : +, -, *, / • Relational Operators : <, >, <=, >=, • Equality Operators : !=, == • Logical Operators : && (AND), ||(OR), !(NOT) • Assignment Arithmetic Operators : +=, *=, /= etc. e.g. a+=5 is equivalent to a=a+5. These are also known as Compound Assignment or Shorthand's
  • 21. Operators by Operations • Increment Operator • Decrement Operators : Similarly pre and post decrement operators e.g. - -a; and a- -; Pre increment : ++a ++a means a = a +1 Pre means before execution of statement e.g. If a=5; Post increment : a++ a++ means a = a +1 Post means after execution of statement e.g. If a=5; printf(“%d”, a); //returns 5 printf(“%d”, ++a); //returns 6 printf(“%d”, a); //returns 6 printf(“%d”, a); //returns 5 printf(“%d”, a++); //returns 5 printf(“%d”, a); //returns 6
  • 22. Hierarchy / Precedence of Operators with their Associativity Operators Category Operators Associativity Unary Operators -, ++, - - , !, sizeof , (type) Right → Left (R→L) Arithmetic * , / , %, Left → Right (L → R) + , - Relational < , <=, >, >= L → R Equality == , != L → R Logical && L → R || L → R Assignment =, +=, -=, *=, /=, %= R → L
  • 23. Data Input and Output • In C you can input/output using input and output library function. • Functions – User Defined and Library Function • These I/O Library functions are getchar(), putchar(), scanf(), printf(), gets() and puts(). • These six functions permits the transfer of information between the computer and the standard I/O devices(e.g. Keyboard, VDU etc.) • An I/O fxs. Can be accessed from anywhere within the program simply by writing the function name.
  • 24. I/O Statements • First we discuss about Single Character and Strings I/O Functions Single Character I/O Functions are getchar() and putchar () String I/O Functions are gets() and puts() char c; Input statement like this c = getchar(); Output statement like this putchar( c ); char name[20]; Input statement like this gets(name); Output statement like this puts(name);
  • 25. scanf() • With the help of scanf() we can enter any type of data and mixed data. In general terms scanf() function is written as scanf( control string, arg1, arg2, arg3…, argn); • Control String consists of individual groups of characters, with one character group for each input data item. • Each character group must begin with a percent(%) sign and followed by conversion character which indicates the type of corresponding data item.
  • 26. Commonly used conversion characters for data input are • c for single character, • d is for decimal integer, • e for floating point value, • f for floating point value, • l is for long etc…. • The arguments are written as variables, arrays, whose types match the corresponding character group in the control string. • Each variable must be preceded by an ampersand (&). • Array name should not begin with &.
  • 27. Examples char name[20]; int roll; float marks; scanf(“ %s %d %f”, name, &roll, &marks); • Formatted scanf() function int a,b,c; scanf(“%3d, %3d %3d”, &a, &b, &c); In the above statement all a,b and c can take maximum of 3 digits.
  • 28. printf() • It is similar to input function scanf(), except that its purpose is to display data rather than to enter it into the computer. • Also there is no ampersand (&) symbol before args. printf(“ %s n %d n %f”, name, roll, marks);
  • 29. Formatted printf() function • example int a,b,c; printf(“%3d, %3d %3d”, a, b, c); • In the above statement all a,b and c can display minimum of 3 digits or spaces instead of digits.
  • 30. Structure of C Program # include < header file> // # is pre-processor directive #define x 5; //symbolic constant int a, b; //global variable declaration int fxn(); // function declaration main() { int i,j,k; // local variable declaration Input statements; Process; Output Statements; }
  • 31. Program 1 # include < stdio.h> main( ) // by default main function is int type { int a=5,b=6,c; c=a+b; printf(“The sum is = %d”, c); }
  • 32. Program 2 # include < stdio.h> main( ) { int a,b,c; scanf(“%d, %d”, &a, &b); c=a+b; printf(“The sum is = %d”, c); }
  • 33. Program 3 # include < stdio.h> void main() /* void is data type which says function should not return any value*/ { int a,b; scanf(“%d, %d”, &a, &b); printf(“The sum is = %d”, a+b); }
  • 34. Program 4 # include < stdio.h> #include <conio.h> void main() { int a,b; clrscr(); printf(“Please enter the value of a & b”); scanf(“%3d, %3d”, &a, &b); printf(“The sum is = %4d”, a+b); }