instagram youtube
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
logo
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Structure Specifiers in C: Syntax and Examples

- Team

Jumat, 8 November 2024 - 17:08

facebook twitter whatsapp telegram line copy

URL berhasil dicopy

facebook icon twitter icon whatsapp icon telegram icon line icon copy

URL berhasil dicopy


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.

Need a Most sensible Device Building Process? Get started Right here!

Complete Stack Developer – MERN StackDiscover Program

Want a Top Software Development Job? Start Here!

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.

Need a Most sensible Device Building Process? Get started Right here!

Complete Stack Developer – MERN StackDiscover Program

Want a Top Software Development Job? Start Here!

%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:

Specifiers_In_C_1

%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:

Specifiers_In_C_2

%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:

Specifiers_In_C_3

%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:

specifiers_In_C_4

%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:

Specifiers_In_C_5.

%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:

Specifiers_In_C_6.

Grasp Core Java 8 Ideas, Java Servlet & Extra!

Java Certification CoachingENROLL NOW

Master Core Java 8 Concepts, Java Servlet & More!

%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:

Specifiers_In_C_7

%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:

Specifiers_In_C_8.

%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:

Specifiers_In_C_9

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

Berita Terkait

Most sensible Recommended Engineering Tactics | 2025
Unfastened Flow Vs General Flow
Be told How AI Automation Is Evolving in 2025
What Is a PHP Compiler & The best way to use it?
Best Leadership Books You Should Read in 2024
Best JavaScript Examples You Must Try in 2025
How to Choose the Right Free Course for the Best Value of Time Spent
What Is Product Design? Definition & Key Principles
Berita ini 11 kali dibaca

Berita Terkait

Selasa, 11 Februari 2025 - 22:32

Revo Uninstaller Pro 5.3.5

Selasa, 11 Februari 2025 - 22:21

Rhinoceros 8.15.25019.13001

Selasa, 11 Februari 2025 - 22:12

Robin YouTube Video Downloader Pro 6.11.10

Selasa, 11 Februari 2025 - 22:08

RoboDK 5.9.0.25039

Selasa, 11 Februari 2025 - 22:05

RoboTask 10.2.2

Selasa, 11 Februari 2025 - 21:18

Room Arranger 10.0.1.714 / 9.6.2.625

Selasa, 11 Februari 2025 - 17:14

Team11 v1.0.2 – Fantasy Cricket App

Selasa, 11 Februari 2025 - 16:20

Sandboxie 1.15.6 / Classic 5.70.6

Berita Terbaru

Headline

Revo Uninstaller Pro 5.3.5

Selasa, 11 Feb 2025 - 22:32

Headline

Rhinoceros 8.15.25019.13001

Selasa, 11 Feb 2025 - 22:21

Headline

Robin YouTube Video Downloader Pro 6.11.10

Selasa, 11 Feb 2025 - 22:12

Headline

RoboDK 5.9.0.25039

Selasa, 11 Feb 2025 - 22:08

Headline

RoboTask 10.2.2

Selasa, 11 Feb 2025 - 22:05