SlideShare una empresa de Scribd logo
1 de 50
INTRODUCTION TO C
PRGRAMMING
About C
Developed in 1972 By Dennis Ritchie at AT & T Bell Lab in
USA
Many ideas took from BCPL and B languages so gave name
C.
Structured programming is possible by using Functions
Extension is easily possible by introducing new libraries
In 1989, C is accepted by ANSI (American national
standardization institute)
2
Why C if we have C++,C# and Java
1. Very difficult to learn C++,C# and Java without knowing
C.
2. Major parts of OS like Windows,UNIX, Linux and Device
drivers etc. are still in C because performance wise C is
better than other.
3. C programs are comparatively time and memory efficient
that’s why programs related to Mobile Devices,
microwave ovens, washing machine etc. written in C.
4. Professional 3D games also written in C because of speed.
3
First C Program
4
/* First C Program */
Original C Compiler IDE
5
Console Screen or Result screen
6
Preprocessor Directive
 The text inside /* and */ is called comment or documentation.
 The statement starting with # (hash sign) is called pre-processor statement.
 The #include is a "preprocessor" directive that tells the compiler to put code
from the header called stdio.h into our program before actually creating the
executable.
 By including header files, you can gain access to many different functions--both
the printf and scanf functions are included in stdio.h.
 getch has its prototype in conio.h header file.
 stdio.h is a header file which has:
o Prototype or declaration only of the library functions
o Predefined constants
Note: Header file does not contain the code of library functions.
It only contains the header or prototype.
 
7
main Function
 A program may contain many functions, but it essentially
contains a main function.
 The return type of main function is kept int type. A program
should return value.
o 0 (zero) in case of normal termination.Non-zero in case of
abnormal termination, i.e. termination due to some error.
 Pre-processing:
o Pre-processing statements are processed first
o All the statements starting with #(hash) sign are preprocessing
statements
o eg. #include and #define
 Compilation: The syntactical validity of the complete program is
checked
o If there is no error the compiler generates the object code (.obj)
 Linking: Symbolic Links are resolved in this phase
o A function call is called symbolic link
o A function can be user defined or ready made function in the library
o The linker substitutes the name of the function with the address of the
first instruction of the function
 Execution: The Instruction of object code are executed one by one.
Steps of Program Execution
Steps of Program Execution
 Pre-processing
 Compilation
 Linking
 Loading
 Execution
Alt + F9
Ctrl+ F9
Types of Errors
 Syntax error: When there is the violation of the grammatical (
Syntax) rule. Detected at the compilation time.
o Semicolon not placed
o Standard Construct not in proper format
o Identifier not declared
 Linker Error: When definition or code of a program is not
found.
o Path of header not properly defined
o Library file not found
o The function name is misspelled
Types of Errors Cont...
 Runtime error: It is generated during execution phase. Due to
mathematical or some operation generated at the run time.
o Division by zero
o Square root of negative number
o File not found
o Trying to write a read only file
 Logical Error: Produced due to wrong logic of program. Tough to
identify and even tougher to remove.
o Variables not initialized
o Boundary case errors in loops
o Misunderstanding of priority and associativity of operators
Types of Statements in C Prog.
 Preprocessing Statements: Also called compiler directives. The
purpose depends on the type of commands.
o # include statement inserts a specified file in our program
o They don't exist after compilation
 Declarative Statements: Used to declare user identifier i.e. to
declare data types for example: int a, b;
o These statements do not exist in the object code.
Types of Statements in C Prog. Cont...
 Executable Statements: The statements for which the executable or
binary code is generated. For
o Input/Output Statements like printf(), scanf()
o Assignment Statements. The syntax is lvalue=rvalue
o Conditional Statements like if(a>b) max =a; else max=b;
o Looping Statements. Also called Iterative statements or repetitive
statements.
For
while
do while
o Function Call like y=sin(x);
Types of Statements in C Prog.
Cont...
 Special Statements: There are four special statements
o break
o continue
o return
o exit
Keywords & Identifiers
 Every C word is classified as either a keyword or an
identifier.
 Keywords: The meaning of some words is reserved in a language
which the programmer can use in predefined manner. Theses are
called keywords or reserve words. For example: do, while, for, if,
break, etc…
 Identifiers refers to the names of variables , function, structure and
array.
 Examples: main, printf, average, sum etc.
32 -Reserved Words (Keywords)
in C
auto
break
case char
const continue
default do
double else
enum extern
float for
goto if
int long
register return
short signed
sizeof static
struct switch
typedef union
unsigned void
volatile while
Rules of Making Identifier or variable
Rule1. Identifier name can be the combination of alphabets (a – z and A - Z),
digit
(0 -9) or underscore (_). E.g. sum50, avgUpto100 etc.
Rule 2. First character must be either alphabet or underscore
E.g. _sum, class_strength,height are valid
123sum, 25th
_var are invalid
Rule 3. Size of identifier may vary from 1 to 31 characters but some compiler
supports bigger size variable name also.
Rule-4. No space and No other special symbols(!,@,%,$,*,(,),-,+,= etc) except
underscore are allowed in identifier name.
 Valid name:  _calulate, _5,a_, __ etc.
 Invalid name: 5@, sum function, Hello@123 etc.
Rule 5. Variable name should not be a keyword or reserve word
Invalid name: interrupt, float, asm, enum etc.
Rule 6: Name of identifier cannot be exactly same as
of name of function or the name of other variable
within the scope of the function.
 What will be output of following program?
 #include<stdio.h>
int sum();
int main(){
int sum;
sum=sum();
printf("%d",sum);
return 0;
}
int sum(){
int a=4,b=6,c;
c=a+b;
return c;}
Output: Compiler error
19
What Are Variables in C?
Variables are named memory location. It may be used for storing a
data value. A variable may take different values at different time
during execution. Example int avg,length etc.
Naming Convention for Variables:
C programmers generally agree on the following conventions for
naming variables.
1. Use meaningfulidentifiers
eg for storing sum use variable name sum
2. Separate “words” within identifiers with underscores or mixed upper
and lower case.
Examples: surfaceArea, surface_Area
surface_area etc
Case Sensitivity
C is case sensitive
It matters whether an identifier, such as a variable name, is uppercase
or lowercase.
Example:
area
Area
AREA
ArEa
are all seen as different variables by the compiler.
Identify valid variable name
 John
 X1
 _
 Group one
 Int_type
 Price$
 char
 (area)
 1ac
 i.j
 if
22
Valid
Valid
Valid
Invalid- no white space allowed
Valid
Invalid- no special symbol allowed other than _
Invalid- no keyword allowed
Invalid- no special symbol allowed other than _
Invalid- numeral cant be 1st
character
Invalid- . Is special symbol
Invalid- no keyword allowed
The C Character Set
A character denotes any alphabet, digit or special symbol
used to represent information.
 Figure 1 shows the valid alphabets,numbers and special
symbols allowed in C.
Constants and Variables
The alphabets, numbers and special symbols when properly
combined form constants, variables and keywords.
A constant is an entity that doesn’t change whereas a
variable is an entity that may change.
In any program we typically do lots of calculations. The
results of these calculations are stored in computers memory.
Like human memory the computer memory also consists of
millions of cells. The calculated values are stored in these
memory cells. To make the retrieval and usage of these
values easy these memory cells (also called memory
locations) are given names. Since the value stored in each
location may change the names given to these locations are
called variable names.
Example of Variable and Constant
Here 3 is stored in a memory location and a name x is given to it.Then we are
assigning a new value 5 to the same memory location x. This would overwrite
the earlier value 3, since a memory location can hold only one value at a time.
Since the location whose name is x can hold different values at different times
x is known as a variable. As against this, 3 or 5 do not change, hence are
known as constants.
Types of C Constants
C constants can be divided into two major categories:
(a) Primary Constants
(b) Secondary Constants
These constants are further categorized as shown in Figure
Integer Constants
Rules for Constructing Integer Constants
1. An integer constant must have at least one digit.
2. It must not have a decimal point.
3. It can be either positive or negative.
4. If no sign precedes an integer constant it is assumed to be
5. positive.
6. No commas or blanks are allowed within an integer constant.
7. The allowable range for integer constants is -32768 to 32767.
 Ex. 426
 +782
 -8000
 -7605
25,000, 67 000 are invalid integers28
Real or Floating Point Constants
 Rules for Constructing Real Constants
 Real constants are often called Floating Point constants. The real constants
could be written in two forms—Fractional form and Exponential form.
 Following rules must be observed while constructing real
constants expressed in fractional form:
1. A real constant must have at least one digit.
2. It must have a decimal point.
3. It could be either positive or negative.
4. Default sign is positive.
5. No commas or blanks are allowed within a real constant.
 Ex.: +325.34, 426. , -32.76 , -48.5792, +.5
29
Exponential Form of Real constants
 Used if the value of the constant is either too small or too large.
 In exponential form of representation, the real constant is
 represented in two parts:
 The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called
exponent.
 Rules:
1. The mantissa part and the exponential part should be separated by a letter e.
2. The mantissa part may have a positive or negative sign.
3. Default sign of mantissa part is positive.
4. The exponent must have at least one digit, which must be a
5. positive or negative integer. Default sign is positive.
6. Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
Ex.: +3.2e-5, 4.1e8, -0.2e+3, -3.2e-5
7500000000 will be 7.5E9 or 75E8
30
Character Constant
Rules for Constructing Character Constants
1. A character constant is a single alphabet, a single digit or a
single special symbol enclosed within single inverted commas.
2. Both the inverted commas should point to the left.
For example, ’A’ is a valid character constant whereas ‘A’ is not.
3. The maximum length of a character constant can be 1
character.
Ex.: 'A‘, 'I‘, '5‘, '='
31
Declaring Variables
Before using a variable, you must give the compiler some
information about the variable; i.e., you must declare it.
The declaration statement has following format
<Data Type> <Variable name>
Data type will indicate the type of variable just like variable
may integer type so data type int will be used.
Examples of variable declarations:
int length ;
float area ;
char ch;
Declaring Variables (con’t)
When we declare a variable
Space is reserved in memory to hold a value of the specified data type
That space is associated with the variable name.
That space is associated with a unique address.
If we are not initializing variable than space has no known value(garbage value).
Visualization of the declaration
int a ;
a
2000
3718
int
Declaring Variables (con’t)
meatbal
ls
FE07
garbage
int
Notes About Variables
You must not use a variable until you somehow give it a
value.
You can not assume that the variable will have a value before
you give it one.
Some compilers do, others do not! This is the source of many
errors that are difficult to find.
Assume your compiler does not give it an initial
value!
Using Variables: Initialization
Variables may be be given initial values, or initialized, when
declared. Examples:
int length = 7 ;
float diameter = 5.9 ;
char initial = ‘A’ ;
7
5.9
‘A’
length
diameter
initial
Data Types
To deal with some data, we have to mention its type (i.e.
whether the data is integral, real, character or string etc.) So data
types are used to tell the types of data.
Data Types Categories
Fundamental or Primitive Data Types
Data Types Range
Data Types Format Specifier
Sample C Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
a=10;
b=‘A’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,a,c);
getch();
} Output:
45637
2000 2001 2002 2003 2004 2005
b
-12
3000 3001 3002 3003 3004 3005
c
00005642
4000 4001 4002 4003 4004 4005
a
Sample C Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
a=10;
b=‘A’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,a,c);
getch();
} Output:
10
2000 2001 2002 2003 2004 2005
b
A
3000 3001 3002 3003 3004 3005
c
50.000000
4000 4001 4002 4003 4004 4005
a
Sample C Program(Modified-1)
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
a=10;
b=‘AB’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,a,c);
getch();
} Output:
10
2000 2001 2002 2003 2004 2005
b
A
3000 3001 3002 3003 3004 3005
c
50.000000
4000 4001 4002 4003 4004 4005
a
Sample C Program(modified-2)
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
a=10;
b=‘ABC’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,a,c);
getch();
} Output:
Sample C Program(modified-2)
#include<stdio.h>
#include<conio.h>
void main()
{
int 5a;
char b;
float c;
5a=10;
b=‘A’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,5a,c);
getch();
} Output:
Sample C Program(Modified-3)
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
a=32769;
b=‘A’;
c=50;
printf(“b=%c ,a=%d,c= %f”,b,a,c);
getch();
} Output:
-32767
2000 2001 2002 2003 2004 2005
b
A
3000 3001 3002 3003 3004 3005
c
50.000000
4000 4001 4002 4003 4004 4005
a
Range of Unsigned int
Overflow in Unsigned int
If number is X where X is greater than 65535 then
New value = X % 65536
If number is Y where Y is less than 0 then
New value = 65536– (Y% 65536) (Take Y without sign)
Example:
unsigned int X=67777;
unsigned int Y= -10;
X=2241
Y=65526
Rang of int
Range of int
If number is X where X is greater than 32767 then
p = X % 65536
if p <=32767 then New value = p
else New value = p - 65536
If number is Y where Y is less than -32768 then
p = Y % 65536 (Take Y without sign)
If p <= 32767 then New value = -p
else New value = 65536 -p
Example:
int X=32768; =-32768
int Y= -65537; = -1

Más contenido relacionado

La actualidad más candente

Basic Electronics components
Basic Electronics componentsBasic Electronics components
Basic Electronics componentsvaibhav jindal
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of ElectronicsVarun A M
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.pptNoumanali748226
 
Presentation on Logical Operators
Presentation on Logical OperatorsPresentation on Logical Operators
Presentation on Logical OperatorsSanjeev Budha
 
An introduction to electronic components
An introduction to electronic componentsAn introduction to electronic components
An introduction to electronic componentsMaria Romina Angustia
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++Jenish Patel
 
TRANSISTORS
 TRANSISTORS TRANSISTORS
TRANSISTORSAJAL A J
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
Connectors and plugs
Connectors and plugsConnectors and plugs
Connectors and plugsBESOR ACADEMY
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Introduction to Basic Electronics
Introduction to Basic ElectronicsIntroduction to Basic Electronics
Introduction to Basic ElectronicsCiel Rampen
 

La actualidad más candente (20)

Basic Electronics components
Basic Electronics componentsBasic Electronics components
Basic Electronics components
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Circuit elements
Circuit elementsCircuit elements
Circuit elements
 
Basics of Electronics
Basics of ElectronicsBasics of Electronics
Basics of Electronics
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt
 
Presentation on Logical Operators
Presentation on Logical OperatorsPresentation on Logical Operators
Presentation on Logical Operators
 
Programming in c
Programming in cProgramming in c
Programming in c
 
An introduction to electronic components
An introduction to electronic componentsAn introduction to electronic components
An introduction to electronic components
 
Method in oop
Method in oopMethod in oop
Method in oop
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
TRANSISTORS
 TRANSISTORS TRANSISTORS
TRANSISTORS
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Electronics ppt
Electronics ppt Electronics ppt
Electronics ppt
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
Connectors and plugs
Connectors and plugsConnectors and plugs
Connectors and plugs
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Introduction to Basic Electronics
Introduction to Basic ElectronicsIntroduction to Basic Electronics
Introduction to Basic Electronics
 

Similar a 5 introduction-to-c

Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centrejatin batra
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptxmadhurij54
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptxRowank2
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language Rowank2
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C languageSachin Verma
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdfAdiseshaK
 

Similar a 5 introduction-to-c (20)

Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
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.pdf
C programming.pdfC programming.pdf
C programming.pdf
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
C intro
C introC intro
C intro
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
Basics of c
Basics of cBasics of c
Basics of c
 
C programming
C programmingC programming
C programming
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptx
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C language
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
 
C programming notes
C programming notesC programming notes
C programming notes
 
C language ppt
C language pptC language ppt
C language ppt
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 

Más de Rohit Shrivastava (13)

1 introduction-to-computer
1 introduction-to-computer1 introduction-to-computer
1 introduction-to-computer
 
17 structure-and-union
17 structure-and-union17 structure-and-union
17 structure-and-union
 
16 dynamic-memory-allocation
16 dynamic-memory-allocation16 dynamic-memory-allocation
16 dynamic-memory-allocation
 
14 strings
14 strings14 strings
14 strings
 
11 functions
11 functions11 functions
11 functions
 
10 array
10 array10 array
10 array
 
8 number-system
8 number-system8 number-system
8 number-system
 
7 decision-control
7 decision-control7 decision-control
7 decision-control
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
2 memory-and-io-devices
2 memory-and-io-devices2 memory-and-io-devices
2 memory-and-io-devices
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 

Último

No Advance 9053900678 Chandigarh Call Girls , Indian Call Girls For Full Ni...
No Advance 9053900678 Chandigarh  Call Girls , Indian Call Girls  For Full Ni...No Advance 9053900678 Chandigarh  Call Girls , Indian Call Girls  For Full Ni...
No Advance 9053900678 Chandigarh Call Girls , Indian Call Girls For Full Ni...Vip call girls In Chandigarh
 
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...Gfnyt.com
 
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171Call Girls Service Gurgaon
 
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...Niamh verma
 
VIP Kolkata Call Girl New Town 👉 8250192130 Available With Room
VIP Kolkata Call Girl New Town 👉 8250192130  Available With RoomVIP Kolkata Call Girl New Town 👉 8250192130  Available With Room
VIP Kolkata Call Girl New Town 👉 8250192130 Available With Roomdivyansh0kumar0
 
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real MeetChandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meetpriyashah722354
 
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...Sheetaleventcompany
 
Hot Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In Ludhiana
Hot  Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In LudhianaHot  Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In Ludhiana
Hot Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In LudhianaRussian Call Girls in Ludhiana
 
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★indiancallgirl4rent
 
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking Models
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking ModelsDehradun Call Girls Service 08854095900 Real Russian Girls Looking Models
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking Modelsindiancallgirl4rent
 
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...Call Girls Noida
 
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabad
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in FaridabadNepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabad
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabadgragteena
 
Bangalore call girl 👯‍♀️@ Simran Independent Call Girls in Bangalore GIUXUZ...
Bangalore call girl  👯‍♀️@ Simran Independent Call Girls in Bangalore  GIUXUZ...Bangalore call girl  👯‍♀️@ Simran Independent Call Girls in Bangalore  GIUXUZ...
Bangalore call girl 👯‍♀️@ Simran Independent Call Girls in Bangalore GIUXUZ...Gfnyt
 
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...gragteena
 
Basics of Anatomy- Language of Anatomy.pptx
Basics of Anatomy- Language of Anatomy.pptxBasics of Anatomy- Language of Anatomy.pptx
Basics of Anatomy- Language of Anatomy.pptxAyush Gupta
 
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...Call Girls Noida
 
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Me
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near MeVIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Me
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Memriyagarg453
 
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...gurkirankumar98700
 
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsi
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsiindian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsi
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana TulsiHigh Profile Call Girls Chandigarh Aarushi
 

Último (20)

No Advance 9053900678 Chandigarh Call Girls , Indian Call Girls For Full Ni...
No Advance 9053900678 Chandigarh  Call Girls , Indian Call Girls  For Full Ni...No Advance 9053900678 Chandigarh  Call Girls , Indian Call Girls  For Full Ni...
No Advance 9053900678 Chandigarh Call Girls , Indian Call Girls For Full Ni...
 
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...
 
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
 
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...
Call Girls Service Chandigarh Gori WhatsApp ❤7710465962 VIP Call Girls Chandi...
 
VIP Kolkata Call Girl New Town 👉 8250192130 Available With Room
VIP Kolkata Call Girl New Town 👉 8250192130  Available With RoomVIP Kolkata Call Girl New Town 👉 8250192130  Available With Room
VIP Kolkata Call Girl New Town 👉 8250192130 Available With Room
 
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real MeetChandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Chandigarh Call Girls 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
 
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...
Call Girl In Zirakpur ❤️♀️@ 9988299661 Zirakpur Call Girls Near Me ❤️♀️@ Sexy...
 
Hot Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In Ludhiana
Hot  Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In LudhianaHot  Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In Ludhiana
Hot Call Girl In Ludhiana 👅🥵 9053'900678 Call Girls Service In Ludhiana
 
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
 
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking Models
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking ModelsDehradun Call Girls Service 08854095900 Real Russian Girls Looking Models
Dehradun Call Girls Service 08854095900 Real Russian Girls Looking Models
 
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...
Vip sexy Call Girls Service In Sector 137,9999965857 Young Female Escorts Ser...
 
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabad
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in FaridabadNepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabad
Nepali Escort Girl * 9999965857 Naughty Call Girls Service in Faridabad
 
Bangalore call girl 👯‍♀️@ Simran Independent Call Girls in Bangalore GIUXUZ...
Bangalore call girl  👯‍♀️@ Simran Independent Call Girls in Bangalore  GIUXUZ...Bangalore call girl  👯‍♀️@ Simran Independent Call Girls in Bangalore  GIUXUZ...
Bangalore call girl 👯‍♀️@ Simran Independent Call Girls in Bangalore GIUXUZ...
 
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...
Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Book me...
 
Basics of Anatomy- Language of Anatomy.pptx
Basics of Anatomy- Language of Anatomy.pptxBasics of Anatomy- Language of Anatomy.pptx
Basics of Anatomy- Language of Anatomy.pptx
 
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...
pOOJA sexy Call Girls In Sector 49,9999965857 Young Female Escorts Service In...
 
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Me
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near MeVIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Me
VIP Call Girls Noida Jhanvi 9711199171 Best VIP Call Girls Near Me
 
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...
Russian Call Girls Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8923113531 ...
 
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsi
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsiindian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsi
indian Call Girl Panchkula ❤️🍑 9907093804 Low Rate Call Girls Ludhiana Tulsi
 
#9711199012# African Student Escorts in Delhi 😘 Call Girls Delhi
#9711199012# African Student Escorts in Delhi 😘 Call Girls Delhi#9711199012# African Student Escorts in Delhi 😘 Call Girls Delhi
#9711199012# African Student Escorts in Delhi 😘 Call Girls Delhi
 

5 introduction-to-c

  • 2. About C Developed in 1972 By Dennis Ritchie at AT & T Bell Lab in USA Many ideas took from BCPL and B languages so gave name C. Structured programming is possible by using Functions Extension is easily possible by introducing new libraries In 1989, C is accepted by ANSI (American national standardization institute) 2
  • 3. Why C if we have C++,C# and Java 1. Very difficult to learn C++,C# and Java without knowing C. 2. Major parts of OS like Windows,UNIX, Linux and Device drivers etc. are still in C because performance wise C is better than other. 3. C programs are comparatively time and memory efficient that’s why programs related to Mobile Devices, microwave ovens, washing machine etc. written in C. 4. Professional 3D games also written in C because of speed. 3
  • 4. First C Program 4 /* First C Program */
  • 6. Console Screen or Result screen 6
  • 7. Preprocessor Directive  The text inside /* and */ is called comment or documentation.  The statement starting with # (hash sign) is called pre-processor statement.  The #include is a "preprocessor" directive that tells the compiler to put code from the header called stdio.h into our program before actually creating the executable.  By including header files, you can gain access to many different functions--both the printf and scanf functions are included in stdio.h.  getch has its prototype in conio.h header file.  stdio.h is a header file which has: o Prototype or declaration only of the library functions o Predefined constants Note: Header file does not contain the code of library functions. It only contains the header or prototype.   7
  • 8. main Function  A program may contain many functions, but it essentially contains a main function.  The return type of main function is kept int type. A program should return value. o 0 (zero) in case of normal termination.Non-zero in case of abnormal termination, i.e. termination due to some error.
  • 9.  Pre-processing: o Pre-processing statements are processed first o All the statements starting with #(hash) sign are preprocessing statements o eg. #include and #define  Compilation: The syntactical validity of the complete program is checked o If there is no error the compiler generates the object code (.obj)  Linking: Symbolic Links are resolved in this phase o A function call is called symbolic link o A function can be user defined or ready made function in the library o The linker substitutes the name of the function with the address of the first instruction of the function  Execution: The Instruction of object code are executed one by one. Steps of Program Execution
  • 10. Steps of Program Execution  Pre-processing  Compilation  Linking  Loading  Execution Alt + F9 Ctrl+ F9
  • 11. Types of Errors  Syntax error: When there is the violation of the grammatical ( Syntax) rule. Detected at the compilation time. o Semicolon not placed o Standard Construct not in proper format o Identifier not declared  Linker Error: When definition or code of a program is not found. o Path of header not properly defined o Library file not found o The function name is misspelled
  • 12. Types of Errors Cont...  Runtime error: It is generated during execution phase. Due to mathematical or some operation generated at the run time. o Division by zero o Square root of negative number o File not found o Trying to write a read only file  Logical Error: Produced due to wrong logic of program. Tough to identify and even tougher to remove. o Variables not initialized o Boundary case errors in loops o Misunderstanding of priority and associativity of operators
  • 13. Types of Statements in C Prog.  Preprocessing Statements: Also called compiler directives. The purpose depends on the type of commands. o # include statement inserts a specified file in our program o They don't exist after compilation  Declarative Statements: Used to declare user identifier i.e. to declare data types for example: int a, b; o These statements do not exist in the object code.
  • 14. Types of Statements in C Prog. Cont...  Executable Statements: The statements for which the executable or binary code is generated. For o Input/Output Statements like printf(), scanf() o Assignment Statements. The syntax is lvalue=rvalue o Conditional Statements like if(a>b) max =a; else max=b; o Looping Statements. Also called Iterative statements or repetitive statements. For while do while o Function Call like y=sin(x);
  • 15. Types of Statements in C Prog. Cont...  Special Statements: There are four special statements o break o continue o return o exit
  • 16. Keywords & Identifiers  Every C word is classified as either a keyword or an identifier.  Keywords: The meaning of some words is reserved in a language which the programmer can use in predefined manner. Theses are called keywords or reserve words. For example: do, while, for, if, break, etc…  Identifiers refers to the names of variables , function, structure and array.  Examples: main, printf, average, sum etc.
  • 17. 32 -Reserved Words (Keywords) in C auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while
  • 18. Rules of Making Identifier or variable Rule1. Identifier name can be the combination of alphabets (a – z and A - Z), digit (0 -9) or underscore (_). E.g. sum50, avgUpto100 etc. Rule 2. First character must be either alphabet or underscore E.g. _sum, class_strength,height are valid 123sum, 25th _var are invalid Rule 3. Size of identifier may vary from 1 to 31 characters but some compiler supports bigger size variable name also. Rule-4. No space and No other special symbols(!,@,%,$,*,(,),-,+,= etc) except underscore are allowed in identifier name.  Valid name:  _calulate, _5,a_, __ etc.  Invalid name: 5@, sum function, Hello@123 etc. Rule 5. Variable name should not be a keyword or reserve word Invalid name: interrupt, float, asm, enum etc.
  • 19. Rule 6: Name of identifier cannot be exactly same as of name of function or the name of other variable within the scope of the function.  What will be output of following program?  #include<stdio.h> int sum(); int main(){ int sum; sum=sum(); printf("%d",sum); return 0; } int sum(){ int a=4,b=6,c; c=a+b; return c;} Output: Compiler error 19
  • 20. What Are Variables in C? Variables are named memory location. It may be used for storing a data value. A variable may take different values at different time during execution. Example int avg,length etc. Naming Convention for Variables: C programmers generally agree on the following conventions for naming variables. 1. Use meaningfulidentifiers eg for storing sum use variable name sum 2. Separate “words” within identifiers with underscores or mixed upper and lower case. Examples: surfaceArea, surface_Area surface_area etc
  • 21. Case Sensitivity C is case sensitive It matters whether an identifier, such as a variable name, is uppercase or lowercase. Example: area Area AREA ArEa are all seen as different variables by the compiler.
  • 22. Identify valid variable name  John  X1  _  Group one  Int_type  Price$  char  (area)  1ac  i.j  if 22 Valid Valid Valid Invalid- no white space allowed Valid Invalid- no special symbol allowed other than _ Invalid- no keyword allowed Invalid- no special symbol allowed other than _ Invalid- numeral cant be 1st character Invalid- . Is special symbol Invalid- no keyword allowed
  • 23.
  • 24. The C Character Set A character denotes any alphabet, digit or special symbol used to represent information.  Figure 1 shows the valid alphabets,numbers and special symbols allowed in C.
  • 25. Constants and Variables The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. A constant is an entity that doesn’t change whereas a variable is an entity that may change. In any program we typically do lots of calculations. The results of these calculations are stored in computers memory. Like human memory the computer memory also consists of millions of cells. The calculated values are stored in these memory cells. To make the retrieval and usage of these values easy these memory cells (also called memory locations) are given names. Since the value stored in each location may change the names given to these locations are called variable names.
  • 26. Example of Variable and Constant Here 3 is stored in a memory location and a name x is given to it.Then we are assigning a new value 5 to the same memory location x. This would overwrite the earlier value 3, since a memory location can hold only one value at a time. Since the location whose name is x can hold different values at different times x is known as a variable. As against this, 3 or 5 do not change, hence are known as constants.
  • 27. Types of C Constants C constants can be divided into two major categories: (a) Primary Constants (b) Secondary Constants These constants are further categorized as shown in Figure
  • 28. Integer Constants Rules for Constructing Integer Constants 1. An integer constant must have at least one digit. 2. It must not have a decimal point. 3. It can be either positive or negative. 4. If no sign precedes an integer constant it is assumed to be 5. positive. 6. No commas or blanks are allowed within an integer constant. 7. The allowable range for integer constants is -32768 to 32767.  Ex. 426  +782  -8000  -7605 25,000, 67 000 are invalid integers28
  • 29. Real or Floating Point Constants  Rules for Constructing Real Constants  Real constants are often called Floating Point constants. The real constants could be written in two forms—Fractional form and Exponential form.  Following rules must be observed while constructing real constants expressed in fractional form: 1. A real constant must have at least one digit. 2. It must have a decimal point. 3. It could be either positive or negative. 4. Default sign is positive. 5. No commas or blanks are allowed within a real constant.  Ex.: +325.34, 426. , -32.76 , -48.5792, +.5 29
  • 30. Exponential Form of Real constants  Used if the value of the constant is either too small or too large.  In exponential form of representation, the real constant is  represented in two parts:  The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.  Rules: 1. The mantissa part and the exponential part should be separated by a letter e. 2. The mantissa part may have a positive or negative sign. 3. Default sign of mantissa part is positive. 4. The exponent must have at least one digit, which must be a 5. positive or negative integer. Default sign is positive. 6. Range of real constants expressed in exponential form is -3.4e38 to 3.4e38. Ex.: +3.2e-5, 4.1e8, -0.2e+3, -3.2e-5 7500000000 will be 7.5E9 or 75E8 30
  • 31. Character Constant Rules for Constructing Character Constants 1. A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. 2. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not. 3. The maximum length of a character constant can be 1 character. Ex.: 'A‘, 'I‘, '5‘, '=' 31
  • 32. Declaring Variables Before using a variable, you must give the compiler some information about the variable; i.e., you must declare it. The declaration statement has following format <Data Type> <Variable name> Data type will indicate the type of variable just like variable may integer type so data type int will be used. Examples of variable declarations: int length ; float area ; char ch;
  • 33. Declaring Variables (con’t) When we declare a variable Space is reserved in memory to hold a value of the specified data type That space is associated with the variable name. That space is associated with a unique address. If we are not initializing variable than space has no known value(garbage value). Visualization of the declaration int a ; a 2000 3718 int
  • 35. Notes About Variables You must not use a variable until you somehow give it a value. You can not assume that the variable will have a value before you give it one. Some compilers do, others do not! This is the source of many errors that are difficult to find. Assume your compiler does not give it an initial value!
  • 36. Using Variables: Initialization Variables may be be given initial values, or initialized, when declared. Examples: int length = 7 ; float diameter = 5.9 ; char initial = ‘A’ ; 7 5.9 ‘A’ length diameter initial
  • 37. Data Types To deal with some data, we have to mention its type (i.e. whether the data is integral, real, character or string etc.) So data types are used to tell the types of data. Data Types Categories
  • 40. Data Types Format Specifier
  • 41. Sample C Program #include<stdio.h> #include<conio.h> void main() { int a; char b; float c; a=10; b=‘A’; c=50; printf(“b=%c ,a=%d,c= %f”,b,a,c); getch(); } Output: 45637 2000 2001 2002 2003 2004 2005 b -12 3000 3001 3002 3003 3004 3005 c 00005642 4000 4001 4002 4003 4004 4005 a
  • 42. Sample C Program #include<stdio.h> #include<conio.h> void main() { int a; char b; float c; a=10; b=‘A’; c=50; printf(“b=%c ,a=%d,c= %f”,b,a,c); getch(); } Output: 10 2000 2001 2002 2003 2004 2005 b A 3000 3001 3002 3003 3004 3005 c 50.000000 4000 4001 4002 4003 4004 4005 a
  • 43. Sample C Program(Modified-1) #include<stdio.h> #include<conio.h> void main() { int a; char b; float c; a=10; b=‘AB’; c=50; printf(“b=%c ,a=%d,c= %f”,b,a,c); getch(); } Output: 10 2000 2001 2002 2003 2004 2005 b A 3000 3001 3002 3003 3004 3005 c 50.000000 4000 4001 4002 4003 4004 4005 a
  • 44. Sample C Program(modified-2) #include<stdio.h> #include<conio.h> void main() { int a; char b; float c; a=10; b=‘ABC’; c=50; printf(“b=%c ,a=%d,c= %f”,b,a,c); getch(); } Output:
  • 45. Sample C Program(modified-2) #include<stdio.h> #include<conio.h> void main() { int 5a; char b; float c; 5a=10; b=‘A’; c=50; printf(“b=%c ,a=%d,c= %f”,b,5a,c); getch(); } Output:
  • 46. Sample C Program(Modified-3) #include<stdio.h> #include<conio.h> void main() { int a; char b; float c; a=32769; b=‘A’; c=50; printf(“b=%c ,a=%d,c= %f”,b,a,c); getch(); } Output: -32767 2000 2001 2002 2003 2004 2005 b A 3000 3001 3002 3003 3004 3005 c 50.000000 4000 4001 4002 4003 4004 4005 a
  • 48. Overflow in Unsigned int If number is X where X is greater than 65535 then New value = X % 65536 If number is Y where Y is less than 0 then New value = 65536– (Y% 65536) (Take Y without sign) Example: unsigned int X=67777; unsigned int Y= -10; X=2241 Y=65526
  • 50. Range of int If number is X where X is greater than 32767 then p = X % 65536 if p <=32767 then New value = p else New value = p - 65536 If number is Y where Y is less than -32768 then p = Y % 65536 (Take Y without sign) If p <= 32767 then New value = -p else New value = 65536 -p Example: int X=32768; =-32768 int Y= -65537; = -1