answersLogoWhite

0


Best Answer

You can certainly do that ...

printf ("This is a number: 12345\n");

... but that does not have the same value as placing the value in a variable and converting the variable into a string ...

int i = 12345;

printf ("This is a number: %d\n", i);

That's the whole point of format specifiers - to initiate a conversion from one place to another.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

Format specifiers are intended to handle variables, not literals.

The following string uses a literal:

"The answer to life, the universe and everything is 42."

The following uses variables:

"A rectangle of width %d units and height %d units has an area of %d square units."

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why not you simply put the decimal integer into the original string as compared to the format specifier?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the format specifier of short integer?

%hd


Why not simply put the decimal integer into the original string as compared to the format specifier?

You can certainly do that ... printf ("This is a number: 12345\n"); ... but that does not have the same value as placing the value in a variable and converting the variable into a string ... int i = 12345; printf ("This is a number: %d\n", i); That's the whole point of format specifiers - to initiate a conversion from one place to another.


Can you declare printf for integer variable?

printf is declared in stdio.hFormat specifier for an integer value is %d.


What are the list of modifier in turbo c language?

%c The character format specifier.%d The integer format specifier.%i The integer format specifier (same as %d).%f The floating-point format specifier.%e The scientific notation format specifier.%E The scientific notation format specifier.%g Uses %f or %e, whichever result is shorter.%G Uses %f or %E, whichever result is shorter.%o The unsigned octal format specifier.%s The string format specifier.%u The unsigned integer format specifier.%x The unsigned hexadecimal format specifier.%X The unsigned hexadecimal format specifier.%p Displays the corresponding argument that is a pointer.%n Records the number of characters written so far.%% Outputs a percent sign.Provided that 'modifier' means 'format specifier'.


Why we use percent you in c language?

%u is a printf format specifier that says to take the next argument and display it as an unsigned decimal number, assuming standard integer length.


Is a decimal number an integer?

A decimal number is not an integer. An integer is a number that is not a fraction, and decimal numbers are decimal fractions.


Is a none repeating decimal an integer?

No, if it has a decimal place then its not an integer


Would a decimal be an integer?

No by definition a decimal number can never be an integer because an integer is a whole number (it can not have any decimal parts).


Can a negative decimal be an integer?

an integer won't have any decimal point


Is a decimal a positive integer?

A decimal is not an integer. However a number with a decimal component can be either positive or negative


Is 7.38 a mixed decimal?

Yes. A mixed decimal is any decimal with an integer ... i.e. 7.38. .38 is the decimal 7 is the integer


Is 184 a integer?

An integer is a number that has no decimal. Yes, 184 is an integer.