Simple Example Program For Printf
Definition:
In C,the printf function writes a formatted string.
Format Specifiers
- %c char single character
- %d (%i) int signed integer
- %e (%E) float or double exponential format
- %f float or double signed decimal
- %g (%G) float or double use %f or %e as required
- %o int unsigned octal value
- %p pointer address stored in pointer
- %s array of char sequence of characters
- %u int unsigned decimal
- %x (%X) int unsigned hex value
Syntax:
printf("Text to be displayed : %format_specifiers", variable);
Simple Example For Print a Number
/* Example program to print a number In C Programming Language*/
// Header Files
#include<stdio.h>
#include<conio.h>
//Main Function
int main()
{
// Assigining the variable num
int num=100;
// Printing the output
printf("Printing a number:%d",num);
// Output screen waits until get a character
getch();
// Returning to the main function
return 0;
}
Sample Output:
Printing a number:100
Simple Example Programs In C Language
- Hello World C Language Example Program
- If Statement Example Program In C Programming Language
- If else Statement Example Program In C Programming Language
- Simple Example Program For If..Else : Example 2
- Switch Case Statement Example Program In C Programming Language
- Simple Example Program For Printf
- Simple C Program for Switch case to Find weekdays name with weekday number
- Simple Program to Print All ASCII Value Table in C Programming
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )