In C programming language, values will also be kind integer, floating-point, unmarried personality, or series of characters. We use layout specifiers in C to show values of a variable of a unique kind.
C incorporates other layout specifiers utilized in printf() and scanf() purposes; on this educational, we can undergo a couple of essential and maximum frequently used layout specifiers in our C systems.
Why Do We Use C Structure Specifiers?
Structure specifiers in C are used to take inputs and print the output of a sort. The logo we use in each and every layout specifier is %. Structure specifiers inform the compiler about the kind of information that should be given or enter and the kind of information that should be imprinted on the display screen.
Now that you’ve a short lived thought of layout specifiers in C, we’ve got a couple of lists of layout specifiers transferring forward.
The Maximum Recurrently Used Structure Specifiers in C
The Maximum frequently used layout specifiers are given beneath:
Structure Specifiers |
Form of Output |
%d or %i |
A decimal integer or signed integer |
%c |
Signed personality |
%f |
Signed waft |
%e |
A floating-point quantity |
%s |
A string or series of personality |
%lf |
double |
%Lf |
Lengthy double |
%o %u |
Octal integer Quick unsigned integer |
%ld |
Lengthy decimal integer |
%x |
Hexadecimal integer |
%p |
Print reminiscence cope with within the hexadecimal shape |
We can undergo a couple of examples that can assist you know how to make use of layout specifiers in printf() and scanf() purposes for a greater figuring out.
%d (Decimal Integer) Structure Specifier
#come with <stdio.h>
int primary()
{
int a=50;
printf(“The integer worth of a is %d n”,a);
go back 0;
}
Output:
%c (Persona) Structure Specifier
#come with <stdio.h>
int primary()
{
char s;
printf(“Input the nature n”);
scanf(“%c”,&s);
printf(“The nature is: %c”,s);
go back 0;
}
Output:
%f (Floating Level) Structure Specifier
#come with <stdio.h>
int primary()
{
waft a=3;
printf(“The floating level of a is %f n”,a);
go back 0;
}
Output:
%e (Floating Pointer Quantity) Structure Specifier
#come with <stdio.h>
int primary()
{
waft a=12.5;
printf(“The floating-point of a is %e n”,a);
go back 0;
}
Output:
%s (String) Structure Specifier
#come with <stdio.h>
int primary()
{
char s[15]=”simplilearn”;
printf(“The string worth of s is %s n”,s);
go back 0;
}
Output:
%lf (Double) Structure Specifier
#come with <stdio.h>
int primary()
{
double d=12.5;
printf(“The double worth of d is %lf n”,d);
go back 0;
}
Output:
%o (octal integer) Structure Specifier
#come with <stdio.h>
int primary()
{
int oct=11;
printf(“The octal integer worth of oct is %o n”,oct);
go back 0;
}
Output:
%x (Hexadecimal Integer) Structure Specifier
#come with <stdio.h>
int primary()
{
int h=14;
printf(“The hexadecimal worth of h is %x n”,h);
go back 0;
}
Output:
%p (Prints Reminiscence Deal with) Structure Specifier
To search out the reminiscence cope with that holds values of a variable, we use the %p layout specifier, and it prints in hexadecimal shape.
#come with <stdio.h>
int primary()
{
int sum=0;
printf(“The reminiscence cope with of sum is %p n”,&sum);
go back 0;
}
output:
With that, you’ll be able to conclude this educational on Structure Specifiers in C
Subsequent Steps
“Information Constructions in C” will also be your subsequent matter. To this point, you might have discovered why we use layout specifiers in C. The following basics would be the information buildings and the sorts in information buildings used for various functions.
If you have an interest in construction a profession in instrument construction, then be happy to discover Simplilearn’s Classes that gives you the work-ready instrument construction coaching you want to prevail lately. Are you most likely searching for a extra complete coaching program in essentially the most in-demand instrument construction talents, equipment, and languages lately? If sure, our Complete Stack Developer – MERN Stack must be the best factor in your profession. Discover the direction and join quickly.
Please tell us within the remark phase beneath when you have any questions in regards to the “Structure specifiers in C ” educational. Our mavens gets again to you on the earliest.
supply: www.simplilearn.com