All articles
c

A program to explain formatted output function PRINTF

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 005

The following code shows how to write a program to explain formatted output function PRINTF

Program

#include <stdio.h>
 
void main()
{
    int a = 34;
    float f = 10.85;
    printf("%6d \n", a);
    printf("%-6d \n", a);
    printf("%f \n", f);
    printf("%10.3f \n", f);
 
    printf("\n");
}

Result

    34
34
10.850000
    10.850

Comments