Structure of c_program_to_input_output

Anil Dutt
Anil DuttTeaching em Rpiit College Karnal
Topics To Be Covered
 Structure Of C Program
 Identifiers
 Basic Data Types And Sizes
 Constants
 Variables
 Expressions
 Operators
 Input/output Statements
Structure of a C Program
Every C program consists of one or more modules called functions. One
of the functions must be called main. The program will always begin by
executing the main function
Each function must contain:
1. A function heading, which consists of the function name, followed
by an optional list of arguments,
1. A list of argument declarations, if arguments are included
3. A compound statement, which comprises the remainder of the
function.
• Each compound statement is enclosed within a pair of braces, { }.
• Compound statements may be nested, one within another
• Each expression statement must end with a semicolon (; )
Example Use Of Comments
The comments at the end of each line have been added in order to
emphasize the overall program organization
Normally a C program will not look like this. Rather, it might
appear as shown below.
Execution of the program results in an interactive dialog such as that
shown below. The user's response is underlined, for clarity.
Radius = 7 3
Area = 28.274309
IDENTIFIERS AND KEYWORDS
 identifiers are names that are given to various program elements,
such as variables, functions and arrays.
 Identifiers consist of letters and digits, in any order, except that the
first character must be a letter.
 Both upper- and lowercase letters are permitted, though common
usage favors the use of lowercase letters for most
 Types of identifiers. Upper- and lowercase letters are not
interchangeable
 The underscore character ( - ) can also be included, and is
considered to be a letter.
 An underscore is often used in the middle of an identifier.
 An identifier may also begin with an underscore, though this is
rarely done in practice.
The following names are not valid identifiers ,For the reasons stated.
The following names are not valid identifiers
For the reasons stated.
Some Other Points About Identifiers
 The identifiers file-manager and file-management are both
grammatically valid. Some compilers may be unable to distinguish
between them, however, because the first eight letters are the same for
each identifier. Therefore, only one of these identifiers should be used
in a single C program.
 As a rule, an identifier should contain enough characters so that its
meaning is readily apparent.
 On the other hand, an excessive number of characters should be
avoided.
 A C program is being written to calculate the future value of an
investment. The identifiers value or future-value are appropriate
symbolic names. However, v or fv would probably be too brief, since
the intended representation of these identifiers is not clear. On the
other hand, the identifier future-value-of-an-investment would be
unsatisfactory because it is too long
Keywords
• There are certain reserved words, called keywords, that have
standard, predefined meanings in C.
• These keywords can be used only for their intended purpose;
• They cannot be used as programmer-defined identifiers.
• The standard keywords are
Some compilers also include some or all of the following keywords.
DATA TYPES
• C supports several different types of data
• Each may be represented differently within the computer’s memory
• The basic data types are listed below (Next Slide).
• Typical memory requirements are also given
• The memory requirements determine the permissible range of values
•
• Note that the memory requirements for each data type may vary
from one C compiler to another
C compilers written for personal computers or small minicomputers
(i.e., computers whose natural word size is less than 32 bits)
generally represent a word as 4 bytes (32 bits)
Points to Remember
• The basic data types can be augmented by the use of the data type
qualijiers short , long, signed and unsigned.
• Integer can be defined as short int , long int or unsigned int
• Usually written simply as short , long or unsigned
• The interpretation of integer data type will vary from one C
compiler to another
• A short int may require less or same memory than an ordinary int
but it will never exceed an ordinary int in word length.
• A long int may require the same amount of memory as an
ordinary in t or it may require more memory, but it will never be
less than an ordinary int .
• If short int and int both have the same memory requirements (e.g.,
2 bytes), then long int will generally have double the
requirements (e.g., 4 bytes)
Points to Remember
• If int and long int both have the same memory requirements (e.g.,
4 bytes) then short int will generally have half the memory
requirements (e.g., 2 bytes)
• An unsigned int has the same memory requirements as an ordinary
i n t . However, in the case of an ordinary int , the leftmost bit is
reserved for the sign.
• With an unsigned int , all of the bits are used to represent the
numerical value. Thus, an unsigned int can be approximately twice
as large as an ordinary int (though, of course, negative values are
not permitted).
• For example, if an ordinary int can vary from -32,768 to +32,767
(which is typical for a 2-byte int ) , then an unsigned int will be
allowed to vary from 0 to 65,535. The unsigned qualifier can also
be applied to other qualified int
CONSTANTS
There are four basic types of constants in C.
1. Integer constants,
2. Floating-point constants
3. Character constants
4. String constants
Integer and floating-point constants represent numbers.
They are often referred to collectively as numeric-type constants.
The following rules apply to all numeric-type constants.
 Commas and blank spaces cannot be included within
 The constant can be preceded by a minus (-) sign if desired
 The value of a constant cannot exceed specified minimum and
maximum bounds.
Integer Constants
• An integer constant is an integer-valued number.
• It consists of a sequence of digits.
• Integer constants can be written in three different number systems:
decimal (base lO), octal (base 8) and hexadecimal (base 16).
• A decimal integer constant can consist of any combination of
digits taken from the set 0 through 9.
• If the constant contains two or more digits, the first digit must be
something other than 0.
Structure of c_program_to_input_output
Octal Integer Constant
An octal integer constant can consist of any combination of
digits taken from the set 0 through 7. However the first digit
must be 0,in order to identify the constant as an octal number.
Hexadecimal Integer Constant
A hexadecimal integer constant must begin with either Ox or OX. It
can then be followed by any combination of digits taken from the sets
0 through 9 and a through f (either upper- or lowercase). Note that
the letters a through f (or A through F) represent the (decimal)
quantities 10 through 15, respectively.
Unsigned and Long Integer Constants
 Unsigned integer constants may exceed the magnitude of ordinary
integer constants by approximately a factor of 2, though they may
not be negative.* An unsigned integer constant can be identified by
appending the letter U (either upper- or lowercase) to the end of the
constant.
 Long integer constants may exceed the magnitude of ordinary
integer constants, to create a long integer constant by appending the
letter L (either upper- or lowercase) to the end of the constant. An
unsigned long integer may be specified by appending the letters UL
to the end of the constant. The letters may be written in either upper-
or lowercase. However, the U must precede the L.
Structure of c_program_to_input_output
Floating-Point Constants
A floating-point constant is a base- 10 number that contains either
a decimal point or an exponent (or both).
Character Constants
A character constant is a single character, enclosed in apostrophes (i.e.,
single quotation marks). Several character constants are shown below.
Escape Sequences
Certain nonprinting characters, as well as the backslash () and the
apostrophe (‘’ ), can be expressed in terms of escape sequences.
An escape sequence always begins with a backward slash and is
followed by one or more special characters.
The commonly used escape sequences are listed below.
String Constants
A string constant consists of any number of consecutive characters
(including none), enclosed in double quotation marks.
Several string constants are shown below.
Note that the string constant "Line 1n Line 2n Line 3" extends over
three lines, because of the newline characters that are embedded
within the string. Thus, this string would be displayed as
Line 1
Line 2
Line 3
Also, notice that the string “ ” is a null (empty) string
EXPRESSIONS
• An expression represents a single data item, such as a number or a
character.
• The expression may consist of a single entity, such as a constant, a
variable, an array element or a reference to a function.
• It may also consist of some combination of such entities,
interconnected by one or more operators.
• Expressions can also represent logical conditions that are either
true or false.
• In C the conditions true and false are represented by the integer
values 1 and 0,respectively
Several simple expressions are shown below.
Structure of c_program_to_input_output
Structure of c_program_to_input_output
OPERATORS
Arithmetic Operators
There are five arithmetic operators in C. They are
The % operator is sometimes referred to as the modulus operator.
There is no exponentiation operator in C.
There is a library finction (POW) to carry out Exponentiation.
Points to Remember
• The operands acted upon by arithmetic operators must represent
numeric values
• Operands can be integer quantities, floating-point quantities
• The remainder operator (%) requires that both operands be
integers and the second operand be nonzero.
• Division operator (/) requires that the second operand be
nonzero.
• Division of one integer quantity by another is referred to as
integer division.
• This operation always results in a truncated quotient (i.e., the
decimal portion of the quotient will be dropped).
• If a division operation is carried out with two floating-point
numbers, or with one floating-point number and one integer, the
result will be a floating-point quotient.
Suppose that a and b are integer variables whose values are 10 and
3, respectively. Several arithmetic expressions involving these
variables are shown below, together with their resulting values.
Now suppose that vl and v2 are floating-point variables whose
values are 12.5 and 2.0, respectively. Several arithmetic
expressions involving these variables are shown below, together
with their resulting values.
Suppose that a and b are integer variables whose values are 11 and
-3, respectively. Several arithmetic expressions involving these
variables are shown below, together with their resulting values.
Let rl and r2 be floating-point variables whose assigned values
are -0.66 and 4.50. Several arithmetic expressions involving these
variables are shown below, together with their resulting values.
Unary Operators
C includes a class of operators that act upon a single operand to
produce a new value. Such operators are known as unary
operators.
Unary operators usually precede their single operands, though
some unary operators are written after their operands.
Perhaps the most common unary operation is unary minus,
where a numerical constant, variable or expression is preceded
by a minus sign.
Relational And Logical Operators
Equality Operators,
Suppose that i, j and k are integer variables whose values are 1, 2 and
3, respectively. Several logical expressions involving these variables
are shown below
logical operators / logical connectives
Assignment Operators
There are several different assignment operators in C.
 Used to form assignment expressions
 Assign the value of an expression to an identifier
 The most commonly used assignment operator is =
 identifier = expression
 where identifier generally represents a variable
 expression represents a constant
Some typical assignment expressions that make use of the =
operator
In the following assignment expressions, suppose that i is an
integer-type variable.
Now suppose that i and j are both integer-type variables, and that j
has been assigned a value of 5. Several assignment expressions that
make use of these two variables are shown below.
Multiple assignments
Assignments Are Carried Out From Right To Left
Above assignment equivalent to
Suppose that i and j are integer variables. The multiple
assignment expression will cause the integer value 5 to be
assigned to both i and j . (To be more precise, 5 is first assigned
to j , and the value of j is then assigned to i.) Similarly, the
multiple assignment expression i = j = 5.9 ,will cause the integer
value 5 to be assigned to both i and j .
Additional Assignment Operators
The assignment expression
is equivalent to
The assignment expression
is equivalent to
expression 1 is an identifier, such as a variable or an array element
Suppose that i and j are integer variables whose values are 5 and 7,
and f and g are floating-point variables whose values are 5.5 and -
3.25. Several assignment expressions that make use of these
variables are shown below. Each expression utilizes the original
values of i, j , f and g
The Conditional operator
 Simple conditional operations can be carried out with the
conditional operator (? :).
 An expression that makes use of the conditional operator is
called a conditional expression.
 A conditional expression is written in the form
When evaluating a conditional expression, expression 1 is evaluated
first. If expression 1 is true (i.e., if its value is nonzero), then
expression 2 is evaluated and this becomes the value of the
conditional expression. However, if expression 1 is false (i.e., if its
value is zero), then expression 3 is evaluated and this becomes the
value of the conditional expression.
In the conditional expression shown below, assume that i is an
integer variable.
The expression (i < 0) is evaluated first. If it is true, the entire
conditional expression takes on the value 0. Otherwise ,the entire
conditional expression takes on the value 100.
In the following conditional expression, assume that f and g are
floating-point variables.
This conditional expression takes on the value off f if it is less than
g; otherwise, the conditional expression takes on the value of g. In
other words, the conditional expression returns the value of the
smaller of the two variables.
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Input/output Statements
The Functions permits the transfer of information between the
computer and the standard input/output devices e.g., a keyboard
and a TV monitor
These six are as follows:
1. getchar
2. putchar
3. scanf
4. printf
5. gets
6. Puts
 The header file required by the standard input/output library
functions is called stdio .h
1. SINGLE CHARACTER INPUT -THE getchar FUNCTION
getchar function is a part of the standard C I/O library
It returns a single character from a standard input device
(typically a keyboard)
The function does not require any arguments, though a pair of
empty parentheses must follow the word getchar
In general terms, a function reference would be written as
character variable = getchar ( ) ;
where character variable refers to some previously declared
character variable.
A C program contains the following statements
char c;
. . . . .
c = getchar();
 The first statement declares that c is a character-type variable
 The second statement causes a single character to be entered
from the standard input device (usually a keyboard)
 Then assigned to c
SINGLE CHARACTER OUTPUT -THE putchar FUNCTION
 Single characters can be displayed i.e., written out of the computer
using the C library function putchar
 It is complementary to the character input function getchar
 It is a part of the standard C I/O library
 It transmits a single character to a standard output device (typically a
TV monitor)
 It must be expressed as an argument to the function, enclosed in
parentheses, following the word putchar
 In general, a function reference would be written as
putchar ( character variable)
 where character variable refers to some previously declared
character variable
A C program contains the following statements
char c;
. . . . .
putchar(c);
 The first statement declares that c is a character-type variable
 The second statement causes the current value of c to be
transmitted to the standard output device (e.g., a TV monitor)
where it will be displayed.
EXAMPLE Lowercase to Uppercase Text Conversion
ENTERING INPUT DATA -THE scanf FUNCTION
 This function can be used to enter any combination of
numerical values ,single characters and strings.
 The function returns the number of data items
 that have been entered successfully
 where control string refers to a string containing certain required
formatting information
 arg1, arg2, . . . argn are arguments that represent the individual
input data items
 The control string consists of individual groups of characters, with
one character group for each input data item
 a single character group will consist of the percent sign, followed
by a conversion character which indicates the type of the
corresponding data item
Commonly Used Conversion Characters for Data Input
 The arguments are written as variables or arrays, whose types
match the corresponding character groups in the control string
 Each variable name must be preceded by an ampersand (a). (The
arguments are actually pointers that indicate where the data items
are stored in the computer's memory
Here is a typical application of a scanf function.
WRITING OUTPUT DATA -THE printf FUNCTION
 Output data can be written from the computer onto a standard
output device using the library function printf
 This function can be used to output any combination of numerical
values, single characters and strings
 In general terms, the printf function is written as
 where control string refers to a string that contains formatting
information,
 and arg7, arg2, . . . , argn are arguments that represent the individual
output data items.
 The arguments can be written as constants, single variable or array
names, or more complex expressions.
 Function references may also be included.
 In a printf function do not represent memory addresses and therefore
are not preceded by ampersands.
 The control string consists of individual groups of characters, with
one character group for each output data item.
 Each character group must begin with a percent sign (%). In its
simplest form,
 An individual character group will consist of the percent sign,
followed by a conversion character indicating the type of the
corresponding data item.
Commonly Used Conversion Characters for Data Output
Here is a simple program that makes use of the printf function.
Notice that the first two arguments within the printf function are
single variables, the third argument is an arithmetic expression,
and the last argument is a function reference that has a numeric
expression as an argument. Executing the program produces the
following output:
2.000000 3.000000 5.000000 2.236068
The following skeletal outline indicates how several different
types of data can be displayed using the printf function
Within the printf function, the control string is "%s %d %f It
contains three character groups. The first character group, %s,
indicates that the first argument (item) represents a string. The
second character group, %indicates that the second argument (part
no) represents a decimal integer value, and the third character group,
%indicates that the third argument (cost) represents a floating-point
value.
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
Structure of c_program_to_input_output
1 de 74

Recomendados

constants, variables and datatypes in C por
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
14.6K visualizações23 slides
Constants in C Programming por
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
6.3K visualizações11 slides
Pointers in C Programming por
Pointers in C ProgrammingPointers in C Programming
Pointers in C ProgrammingJasleen Kaur (Chandigarh University)
35K visualizações26 slides
Strings por
StringsStrings
StringsMitali Chugh
5.7K visualizações24 slides
Union in C programming por
Union in C programmingUnion in C programming
Union in C programmingKamal Acharya
6.4K visualizações5 slides
Functions in c por
Functions in cFunctions in c
Functions in csunila tharagaturi
1.5K visualizações42 slides

Mais conteúdo relacionado

Mais procurados

Programming in c Arrays por
Programming in c ArraysProgramming in c Arrays
Programming in c Arraysjanani thirupathi
24K visualizações31 slides
Data Types and Variables In C Programming por
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
16.8K visualizações33 slides
Strings in C por
Strings in CStrings in C
Strings in CKamal Acharya
24.2K visualizações22 slides
Tokens in C++ por
Tokens in C++Tokens in C++
Tokens in C++Mahender Boda
6.5K visualizações16 slides
Pointer in c por
Pointer in cPointer in c
Pointer in clavanya marichamy
15.8K visualizações14 slides
Function in C program por
Function in C programFunction in C program
Function in C programNurul Zakiah Zamri Tan
70.6K visualizações23 slides

Mais procurados(20)

Programming in c Arrays por janani thirupathi
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi24K visualizações
Data Types and Variables In C Programming por Kamal Acharya
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya16.8K visualizações
Strings in C por Kamal Acharya
Strings in CStrings in C
Strings in C
Kamal Acharya24.2K visualizações
Tokens in C++ por Mahender Boda
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda6.5K visualizações
Pointer in c por lavanya marichamy
Pointer in cPointer in c
Pointer in c
lavanya marichamy15.8K visualizações
Decision making statements in C programming por Rabin BK
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
Rabin BK5.6K visualizações
C Tokens por Ripon Hossain
C TokensC Tokens
C Tokens
Ripon Hossain999 visualizações
Variables in C Programming por programming9
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming99.1K visualizações
Presentation on Function in C Programming por Shuvongkor Barman
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman14.9K visualizações
Constants and variables in c programming por Chitrank Dixit
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
Chitrank Dixit7.6K visualizações
Character Array and String por Tasnima Hamid
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid1K visualizações
Declaration of variables por Maria Stella Solon
Declaration of variablesDeclaration of variables
Declaration of variables
Maria Stella Solon681 visualizações
RECURSION IN C por v_jk
RECURSION IN C RECURSION IN C
RECURSION IN C
v_jk14.2K visualizações
Introduction to c programming por ABHISHEK fulwadhwa
Introduction to c programmingIntroduction to c programming
Introduction to c programming
ABHISHEK fulwadhwa4.6K visualizações
What is identifier c programming por Rumman Ansari
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari9.9K visualizações
datatypes and variables in c language por Rai University
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
Rai University8.9K visualizações
Pointers in C Language por madan reddy
Pointers in C LanguagePointers in C Language
Pointers in C Language
madan reddy277 visualizações
Function C programming por Appili Vamsi Krishna
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna11.6K visualizações

Destaque

Structure of a C program por
Structure of a C programStructure of a C program
Structure of a C programDavid Livingston J
22.5K visualizações16 slides
C material por
C materialC material
C materialtarique472
5.8K visualizações70 slides
Basics of C programming por
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
165.5K visualizações39 slides
C LANGUAGE - BESTECH SOLUTIONS por
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH SOLUTIONS
405 visualizações33 slides
Introduction to C programming por
Introduction to C programmingIntroduction to C programming
Introduction to C programmingRutvik Pensionwar
1.1K visualizações17 slides
Structure in C por
Structure in CStructure in C
Structure in CFazle Rabbi Ador
14.8K visualizações30 slides

Destaque(20)

Structure of a C program por David Livingston J
Structure of a C programStructure of a C program
Structure of a C program
David Livingston J22.5K visualizações
C material por tarique472
C materialC material
C material
tarique4725.8K visualizações
Basics of C programming por avikdhupar
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar165.5K visualizações
C LANGUAGE - BESTECH SOLUTIONS por BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
BESTECH SOLUTIONS405 visualizações
Introduction to C programming por Rutvik Pensionwar
Introduction to C programmingIntroduction to C programming
Introduction to C programming
Rutvik Pensionwar1.1K visualizações
Structure in C por Fazle Rabbi Ador
Structure in CStructure in C
Structure in C
Fazle Rabbi Ador14.8K visualizações
Overview of c language por shalini392
Overview of c languageOverview of c language
Overview of c language
shalini39228.2K visualizações
INTRODUCTION TO C PROGRAMMING por Abhishek Dwivedi
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi208.7K visualizações
Btech i pic u-1 introduction to c language por Rai University
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
Rai University547 visualizações
UNIX introduction por MUFIX Community
UNIX introductionUNIX introduction
UNIX introduction
MUFIX Community1.1K visualizações
Structure c por thirumalaikumar3
Structure cStructure c
Structure c
thirumalaikumar37.2K visualizações
Unix Introduction por Ananthi
Unix IntroductionUnix Introduction
Unix Introduction
Ananthi 1K visualizações
Linking in MS-Dos System por Satyamevjayte Haxor
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
Satyamevjayte Haxor9K visualizações
File handling-dutt por Anil Dutt
File handling-duttFile handling-dutt
File handling-dutt
Anil Dutt634 visualizações
C chap02 por Kamran
C chap02C chap02
C chap02
Kamran478 visualizações
Data structures using C por Pdr Patnaik
Data structures using CData structures using C
Data structures using C
Pdr Patnaik3.7K visualizações
[UX Project] C-Saw por Tzuyea (Zia) Su
[UX Project] C-Saw[UX Project] C-Saw
[UX Project] C-Saw
Tzuyea (Zia) Su859 visualizações
Input Output Management In C Programming por Kamal Acharya
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C Programming
Kamal Acharya3.9K visualizações

Similar a Structure of c_program_to_input_output

Module 1:Introduction por
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
294 visualizações105 slides
Constants Variables Datatypes by Mrs. Sowmya Jyothi por
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
905 visualizações43 slides
Constant, variables, data types por
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
3.6K visualizações13 slides
Data type por
Data typeData type
Data typeIsha Aggarwal
307 visualizações7 slides
C programming tutorial por
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
3.2K visualizações163 slides
Chap 1 and 2 por
Chap 1 and 2Chap 1 and 2
Chap 1 and 2Selva Arrunaa Mathavan
351 visualizações82 slides

Similar a Structure of c_program_to_input_output(20)

Module 1:Introduction por nikshaikh786
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
nikshaikh786294 visualizações
Constants Variables Datatypes by Mrs. Sowmya Jyothi por SowmyaJyothi3
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3905 visualizações
Constant, variables, data types por Pratik Devmurari
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari3.6K visualizações
Data type por Isha Aggarwal
Data typeData type
Data type
Isha Aggarwal307 visualizações
C programming tutorial por Mohit Saini
C programming tutorialC programming tutorial
C programming tutorial
Mohit Saini3.2K visualizações
C tokens.pptx por NavyaParashir
C tokens.pptxC tokens.pptx
C tokens.pptx
NavyaParashir13 visualizações
Bsc cs i pic u-2 datatypes and variables in c language por Rai University
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Rai University852 visualizações
Btech i pic u-2 datatypes and variables in c language por Rai University
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Rai University509 visualizações
Mca i pic u-2 datatypes and variables in c language por Rai University
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
Rai University1.1K visualizações
Diploma ii cfpc u-2 datatypes and variables in c language por Rai University
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University845 visualizações
FUNDAMENTAL OF C por KRUNAL RAVAL
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
KRUNAL RAVAL1.6K visualizações
INTRODUCTION TO C++.pptx por MamataAnilgod
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptx
MamataAnilgod16 visualizações
CProgrammingTutorial por Muthuselvam RS
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS4K visualizações
CONSTANTS, VARIABLES & DATATYPES IN C por Sahithi Naraparaju
CONSTANTS, VARIABLES & DATATYPES IN CCONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju1.1K visualizações
C the basic concepts por Abhinav Vatsa
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa58.2K visualizações
Basics of C.ppt por SangramNayak23
Basics of C.pptBasics of C.ppt
Basics of C.ppt
SangramNayak236 visualizações
Basics of C.ppt por RohanJoshi290109
Basics of C.pptBasics of C.ppt
Basics of C.ppt
RohanJoshi2901096 visualizações
Basics of C.ppt por TanuGohel
Basics of C.pptBasics of C.ppt
Basics of C.ppt
TanuGohel3 visualizações

Último

Building source code level profiler for C++.pdf por
Building source code level profiler for C++.pdfBuilding source code level profiler for C++.pdf
Building source code level profiler for C++.pdfssuser28de9e
12 visualizações38 slides
PIT Interpretation - Use only PIT-W EN.ppt por
PIT Interpretation - Use only PIT-W EN.pptPIT Interpretation - Use only PIT-W EN.ppt
PIT Interpretation - Use only PIT-W EN.pptRabindra Shrestha
5 visualizações45 slides
taylor-2005-classical-mechanics.pdf por
taylor-2005-classical-mechanics.pdftaylor-2005-classical-mechanics.pdf
taylor-2005-classical-mechanics.pdfArturoArreola10
40 visualizações808 slides
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdf por
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdfASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdf
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdfAlhamduKure
11 visualizações11 slides
DevFest 2023 Daegu Speech_이재규, Implementing easy and simple chat with gol... por
DevFest 2023 Daegu Speech_이재규,  Implementing easy and simple chat with gol...DevFest 2023 Daegu Speech_이재규,  Implementing easy and simple chat with gol...
DevFest 2023 Daegu Speech_이재규, Implementing easy and simple chat with gol...JQLEE6
16 visualizações31 slides
CPM Schedule Float.pptx por
CPM Schedule Float.pptxCPM Schedule Float.pptx
CPM Schedule Float.pptxMathew Joseph
9 visualizações5 slides

Último(20)

Building source code level profiler for C++.pdf por ssuser28de9e
Building source code level profiler for C++.pdfBuilding source code level profiler for C++.pdf
Building source code level profiler for C++.pdf
ssuser28de9e12 visualizações
PIT Interpretation - Use only PIT-W EN.ppt por Rabindra Shrestha
PIT Interpretation - Use only PIT-W EN.pptPIT Interpretation - Use only PIT-W EN.ppt
PIT Interpretation - Use only PIT-W EN.ppt
Rabindra Shrestha5 visualizações
taylor-2005-classical-mechanics.pdf por ArturoArreola10
taylor-2005-classical-mechanics.pdftaylor-2005-classical-mechanics.pdf
taylor-2005-classical-mechanics.pdf
ArturoArreola1040 visualizações
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdf por AlhamduKure
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdfASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdf
ASSIGNMENTS ON FUZZY LOGIC IN TRAFFIC FLOW.pdf
AlhamduKure11 visualizações
DevFest 2023 Daegu Speech_이재규, Implementing easy and simple chat with gol... por JQLEE6
DevFest 2023 Daegu Speech_이재규,  Implementing easy and simple chat with gol...DevFest 2023 Daegu Speech_이재규,  Implementing easy and simple chat with gol...
DevFest 2023 Daegu Speech_이재규, Implementing easy and simple chat with gol...
JQLEE616 visualizações
CPM Schedule Float.pptx por Mathew Joseph
CPM Schedule Float.pptxCPM Schedule Float.pptx
CPM Schedule Float.pptx
Mathew Joseph9 visualizações
unit 1.pptx por rrbornarecm
unit 1.pptxunit 1.pptx
unit 1.pptx
rrbornarecm6 visualizações
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth por Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 28 visualizações
REPORT Data Science EXPERT LECTURE.doc por Parulkhatri11
REPORT Data Science EXPERT LECTURE.docREPORT Data Science EXPERT LECTURE.doc
REPORT Data Science EXPERT LECTURE.doc
Parulkhatri117 visualizações
Module-1, Chapter-2 Data Types, Variables, and Arrays por Demian Antony D'Mello
Module-1, Chapter-2 Data Types, Variables, and ArraysModule-1, Chapter-2 Data Types, Variables, and Arrays
Module-1, Chapter-2 Data Types, Variables, and Arrays
Demian Antony D'Mello19 visualizações
Integrating Sustainable Development Goals (SDGs) in School Education por SheetalTank1
Integrating Sustainable Development Goals (SDGs) in School EducationIntegrating Sustainable Development Goals (SDGs) in School Education
Integrating Sustainable Development Goals (SDGs) in School Education
SheetalTank120 visualizações
Global airborne satcom market report por defencereport78
Global airborne satcom market reportGlobal airborne satcom market report
Global airborne satcom market report
defencereport788 visualizações
Field Programmable Gate Arrays : Architecture por Usha Mehta
Field Programmable Gate Arrays : ArchitectureField Programmable Gate Arrays : Architecture
Field Programmable Gate Arrays : Architecture
Usha Mehta33 visualizações
Basic Design Flow for Field Programmable Gate Arrays por Usha Mehta
Basic Design Flow for Field Programmable Gate ArraysBasic Design Flow for Field Programmable Gate Arrays
Basic Design Flow for Field Programmable Gate Arrays
Usha Mehta24 visualizações
IRJET-Productivity Enhancement Using Method Study.pdf por SahilBavdhankar
IRJET-Productivity Enhancement Using Method Study.pdfIRJET-Productivity Enhancement Using Method Study.pdf
IRJET-Productivity Enhancement Using Method Study.pdf
SahilBavdhankar11 visualizações
dummy.pptx por JamesLamp
dummy.pptxdummy.pptx
dummy.pptx
JamesLamp7 visualizações
Details of Acoustic Liner for selection of material por rafiqalisyed
Details of Acoustic Liner for selection of materialDetails of Acoustic Liner for selection of material
Details of Acoustic Liner for selection of material
rafiqalisyed5 visualizações
Programmable Logic Devices : SPLD and CPLD por Usha Mehta
Programmable Logic Devices : SPLD and CPLDProgrammable Logic Devices : SPLD and CPLD
Programmable Logic Devices : SPLD and CPLD
Usha Mehta44 visualizações
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R... por IJCNCJournal
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
IJCNCJournal5 visualizações

Structure of c_program_to_input_output

  • 1. Topics To Be Covered  Structure Of C Program  Identifiers  Basic Data Types And Sizes  Constants  Variables  Expressions  Operators  Input/output Statements
  • 2. Structure of a C Program Every C program consists of one or more modules called functions. One of the functions must be called main. The program will always begin by executing the main function Each function must contain: 1. A function heading, which consists of the function name, followed by an optional list of arguments, 1. A list of argument declarations, if arguments are included 3. A compound statement, which comprises the remainder of the function. • Each compound statement is enclosed within a pair of braces, { }. • Compound statements may be nested, one within another • Each expression statement must end with a semicolon (; )
  • 3. Example Use Of Comments
  • 4. The comments at the end of each line have been added in order to emphasize the overall program organization Normally a C program will not look like this. Rather, it might appear as shown below. Execution of the program results in an interactive dialog such as that shown below. The user's response is underlined, for clarity. Radius = 7 3 Area = 28.274309
  • 5. IDENTIFIERS AND KEYWORDS  identifiers are names that are given to various program elements, such as variables, functions and arrays.  Identifiers consist of letters and digits, in any order, except that the first character must be a letter.  Both upper- and lowercase letters are permitted, though common usage favors the use of lowercase letters for most  Types of identifiers. Upper- and lowercase letters are not interchangeable  The underscore character ( - ) can also be included, and is considered to be a letter.  An underscore is often used in the middle of an identifier.  An identifier may also begin with an underscore, though this is rarely done in practice.
  • 6. The following names are not valid identifiers ,For the reasons stated. The following names are not valid identifiers For the reasons stated.
  • 7. Some Other Points About Identifiers  The identifiers file-manager and file-management are both grammatically valid. Some compilers may be unable to distinguish between them, however, because the first eight letters are the same for each identifier. Therefore, only one of these identifiers should be used in a single C program.  As a rule, an identifier should contain enough characters so that its meaning is readily apparent.  On the other hand, an excessive number of characters should be avoided.  A C program is being written to calculate the future value of an investment. The identifiers value or future-value are appropriate symbolic names. However, v or fv would probably be too brief, since the intended representation of these identifiers is not clear. On the other hand, the identifier future-value-of-an-investment would be unsatisfactory because it is too long
  • 8. Keywords • There are certain reserved words, called keywords, that have standard, predefined meanings in C. • These keywords can be used only for their intended purpose; • They cannot be used as programmer-defined identifiers.
  • 9. • The standard keywords are Some compilers also include some or all of the following keywords.
  • 10. DATA TYPES • C supports several different types of data • Each may be represented differently within the computer’s memory • The basic data types are listed below (Next Slide). • Typical memory requirements are also given • The memory requirements determine the permissible range of values • • Note that the memory requirements for each data type may vary from one C compiler to another
  • 11. C compilers written for personal computers or small minicomputers (i.e., computers whose natural word size is less than 32 bits) generally represent a word as 4 bytes (32 bits)
  • 12. Points to Remember • The basic data types can be augmented by the use of the data type qualijiers short , long, signed and unsigned. • Integer can be defined as short int , long int or unsigned int • Usually written simply as short , long or unsigned • The interpretation of integer data type will vary from one C compiler to another • A short int may require less or same memory than an ordinary int but it will never exceed an ordinary int in word length. • A long int may require the same amount of memory as an ordinary in t or it may require more memory, but it will never be less than an ordinary int . • If short int and int both have the same memory requirements (e.g., 2 bytes), then long int will generally have double the requirements (e.g., 4 bytes)
  • 13. Points to Remember • If int and long int both have the same memory requirements (e.g., 4 bytes) then short int will generally have half the memory requirements (e.g., 2 bytes) • An unsigned int has the same memory requirements as an ordinary i n t . However, in the case of an ordinary int , the leftmost bit is reserved for the sign. • With an unsigned int , all of the bits are used to represent the numerical value. Thus, an unsigned int can be approximately twice as large as an ordinary int (though, of course, negative values are not permitted). • For example, if an ordinary int can vary from -32,768 to +32,767 (which is typical for a 2-byte int ) , then an unsigned int will be allowed to vary from 0 to 65,535. The unsigned qualifier can also be applied to other qualified int
  • 14. CONSTANTS There are four basic types of constants in C. 1. Integer constants, 2. Floating-point constants 3. Character constants 4. String constants Integer and floating-point constants represent numbers. They are often referred to collectively as numeric-type constants. The following rules apply to all numeric-type constants.  Commas and blank spaces cannot be included within  The constant can be preceded by a minus (-) sign if desired  The value of a constant cannot exceed specified minimum and maximum bounds.
  • 15. Integer Constants • An integer constant is an integer-valued number. • It consists of a sequence of digits. • Integer constants can be written in three different number systems: decimal (base lO), octal (base 8) and hexadecimal (base 16). • A decimal integer constant can consist of any combination of digits taken from the set 0 through 9. • If the constant contains two or more digits, the first digit must be something other than 0.
  • 17. Octal Integer Constant An octal integer constant can consist of any combination of digits taken from the set 0 through 7. However the first digit must be 0,in order to identify the constant as an octal number.
  • 18. Hexadecimal Integer Constant A hexadecimal integer constant must begin with either Ox or OX. It can then be followed by any combination of digits taken from the sets 0 through 9 and a through f (either upper- or lowercase). Note that the letters a through f (or A through F) represent the (decimal) quantities 10 through 15, respectively.
  • 19. Unsigned and Long Integer Constants  Unsigned integer constants may exceed the magnitude of ordinary integer constants by approximately a factor of 2, though they may not be negative.* An unsigned integer constant can be identified by appending the letter U (either upper- or lowercase) to the end of the constant.  Long integer constants may exceed the magnitude of ordinary integer constants, to create a long integer constant by appending the letter L (either upper- or lowercase) to the end of the constant. An unsigned long integer may be specified by appending the letters UL to the end of the constant. The letters may be written in either upper- or lowercase. However, the U must precede the L.
  • 21. Floating-Point Constants A floating-point constant is a base- 10 number that contains either a decimal point or an exponent (or both).
  • 22. Character Constants A character constant is a single character, enclosed in apostrophes (i.e., single quotation marks). Several character constants are shown below. Escape Sequences Certain nonprinting characters, as well as the backslash () and the apostrophe (‘’ ), can be expressed in terms of escape sequences. An escape sequence always begins with a backward slash and is followed by one or more special characters.
  • 23. The commonly used escape sequences are listed below.
  • 24. String Constants A string constant consists of any number of consecutive characters (including none), enclosed in double quotation marks. Several string constants are shown below. Note that the string constant "Line 1n Line 2n Line 3" extends over three lines, because of the newline characters that are embedded within the string. Thus, this string would be displayed as Line 1 Line 2 Line 3 Also, notice that the string “ ” is a null (empty) string
  • 25. EXPRESSIONS • An expression represents a single data item, such as a number or a character. • The expression may consist of a single entity, such as a constant, a variable, an array element or a reference to a function. • It may also consist of some combination of such entities, interconnected by one or more operators. • Expressions can also represent logical conditions that are either true or false. • In C the conditions true and false are represented by the integer values 1 and 0,respectively
  • 26. Several simple expressions are shown below.
  • 29. OPERATORS Arithmetic Operators There are five arithmetic operators in C. They are The % operator is sometimes referred to as the modulus operator. There is no exponentiation operator in C. There is a library finction (POW) to carry out Exponentiation.
  • 30. Points to Remember • The operands acted upon by arithmetic operators must represent numeric values • Operands can be integer quantities, floating-point quantities • The remainder operator (%) requires that both operands be integers and the second operand be nonzero. • Division operator (/) requires that the second operand be nonzero. • Division of one integer quantity by another is referred to as integer division. • This operation always results in a truncated quotient (i.e., the decimal portion of the quotient will be dropped). • If a division operation is carried out with two floating-point numbers, or with one floating-point number and one integer, the result will be a floating-point quotient.
  • 31. Suppose that a and b are integer variables whose values are 10 and 3, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values.
  • 32. Now suppose that vl and v2 are floating-point variables whose values are 12.5 and 2.0, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values.
  • 33. Suppose that a and b are integer variables whose values are 11 and -3, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values.
  • 34. Let rl and r2 be floating-point variables whose assigned values are -0.66 and 4.50. Several arithmetic expressions involving these variables are shown below, together with their resulting values.
  • 35. Unary Operators C includes a class of operators that act upon a single operand to produce a new value. Such operators are known as unary operators. Unary operators usually precede their single operands, though some unary operators are written after their operands. Perhaps the most common unary operation is unary minus, where a numerical constant, variable or expression is preceded by a minus sign.
  • 36. Relational And Logical Operators Equality Operators,
  • 37. Suppose that i, j and k are integer variables whose values are 1, 2 and 3, respectively. Several logical expressions involving these variables are shown below logical operators / logical connectives
  • 38. Assignment Operators There are several different assignment operators in C.  Used to form assignment expressions  Assign the value of an expression to an identifier  The most commonly used assignment operator is =  identifier = expression  where identifier generally represents a variable  expression represents a constant
  • 39. Some typical assignment expressions that make use of the = operator In the following assignment expressions, suppose that i is an integer-type variable.
  • 40. Now suppose that i and j are both integer-type variables, and that j has been assigned a value of 5. Several assignment expressions that make use of these two variables are shown below.
  • 41. Multiple assignments Assignments Are Carried Out From Right To Left Above assignment equivalent to Suppose that i and j are integer variables. The multiple assignment expression will cause the integer value 5 to be assigned to both i and j . (To be more precise, 5 is first assigned to j , and the value of j is then assigned to i.) Similarly, the multiple assignment expression i = j = 5.9 ,will cause the integer value 5 to be assigned to both i and j .
  • 42. Additional Assignment Operators The assignment expression is equivalent to The assignment expression is equivalent to expression 1 is an identifier, such as a variable or an array element
  • 43. Suppose that i and j are integer variables whose values are 5 and 7, and f and g are floating-point variables whose values are 5.5 and - 3.25. Several assignment expressions that make use of these variables are shown below. Each expression utilizes the original values of i, j , f and g
  • 44. The Conditional operator  Simple conditional operations can be carried out with the conditional operator (? :).  An expression that makes use of the conditional operator is called a conditional expression.  A conditional expression is written in the form When evaluating a conditional expression, expression 1 is evaluated first. If expression 1 is true (i.e., if its value is nonzero), then expression 2 is evaluated and this becomes the value of the conditional expression. However, if expression 1 is false (i.e., if its value is zero), then expression 3 is evaluated and this becomes the value of the conditional expression.
  • 45. In the conditional expression shown below, assume that i is an integer variable. The expression (i < 0) is evaluated first. If it is true, the entire conditional expression takes on the value 0. Otherwise ,the entire conditional expression takes on the value 100. In the following conditional expression, assume that f and g are floating-point variables. This conditional expression takes on the value off f if it is less than g; otherwise, the conditional expression takes on the value of g. In other words, the conditional expression returns the value of the smaller of the two variables.
  • 55. Input/output Statements The Functions permits the transfer of information between the computer and the standard input/output devices e.g., a keyboard and a TV monitor These six are as follows: 1. getchar 2. putchar 3. scanf 4. printf 5. gets 6. Puts  The header file required by the standard input/output library functions is called stdio .h
  • 56. 1. SINGLE CHARACTER INPUT -THE getchar FUNCTION getchar function is a part of the standard C I/O library It returns a single character from a standard input device (typically a keyboard) The function does not require any arguments, though a pair of empty parentheses must follow the word getchar In general terms, a function reference would be written as character variable = getchar ( ) ; where character variable refers to some previously declared character variable.
  • 57. A C program contains the following statements char c; . . . . . c = getchar();  The first statement declares that c is a character-type variable  The second statement causes a single character to be entered from the standard input device (usually a keyboard)  Then assigned to c
  • 58. SINGLE CHARACTER OUTPUT -THE putchar FUNCTION  Single characters can be displayed i.e., written out of the computer using the C library function putchar  It is complementary to the character input function getchar  It is a part of the standard C I/O library  It transmits a single character to a standard output device (typically a TV monitor)  It must be expressed as an argument to the function, enclosed in parentheses, following the word putchar  In general, a function reference would be written as putchar ( character variable)  where character variable refers to some previously declared character variable
  • 59. A C program contains the following statements char c; . . . . . putchar(c);  The first statement declares that c is a character-type variable  The second statement causes the current value of c to be transmitted to the standard output device (e.g., a TV monitor) where it will be displayed.
  • 60. EXAMPLE Lowercase to Uppercase Text Conversion
  • 61. ENTERING INPUT DATA -THE scanf FUNCTION  This function can be used to enter any combination of numerical values ,single characters and strings.  The function returns the number of data items  that have been entered successfully  where control string refers to a string containing certain required formatting information  arg1, arg2, . . . argn are arguments that represent the individual input data items  The control string consists of individual groups of characters, with one character group for each input data item  a single character group will consist of the percent sign, followed by a conversion character which indicates the type of the corresponding data item
  • 62. Commonly Used Conversion Characters for Data Input
  • 63.  The arguments are written as variables or arrays, whose types match the corresponding character groups in the control string  Each variable name must be preceded by an ampersand (a). (The arguments are actually pointers that indicate where the data items are stored in the computer's memory Here is a typical application of a scanf function.
  • 64. WRITING OUTPUT DATA -THE printf FUNCTION  Output data can be written from the computer onto a standard output device using the library function printf  This function can be used to output any combination of numerical values, single characters and strings  In general terms, the printf function is written as
  • 65.  where control string refers to a string that contains formatting information,  and arg7, arg2, . . . , argn are arguments that represent the individual output data items.  The arguments can be written as constants, single variable or array names, or more complex expressions.  Function references may also be included.  In a printf function do not represent memory addresses and therefore are not preceded by ampersands.  The control string consists of individual groups of characters, with one character group for each output data item.  Each character group must begin with a percent sign (%). In its simplest form,  An individual character group will consist of the percent sign, followed by a conversion character indicating the type of the corresponding data item.
  • 66. Commonly Used Conversion Characters for Data Output
  • 67. Here is a simple program that makes use of the printf function. Notice that the first two arguments within the printf function are single variables, the third argument is an arithmetic expression, and the last argument is a function reference that has a numeric expression as an argument. Executing the program produces the following output: 2.000000 3.000000 5.000000 2.236068
  • 68. The following skeletal outline indicates how several different types of data can be displayed using the printf function Within the printf function, the control string is "%s %d %f It contains three character groups. The first character group, %s, indicates that the first argument (item) represents a string. The second character group, %indicates that the second argument (part no) represents a decimal integer value, and the third character group, %indicates that the third argument (cost) represents a floating-point value.