%i Format Specifier

About %i Format Specifier :

Here, in this page we will discuss about the %i format specifier in C. They are used to take input and print output of different type. %i is one of the format specifier.

format specifier

%i Format Specifier :

  • %i is a format specifier used to take input in scanf and print output in printf as integer. % is used before any format specifier to check which data type is used.
  • %i takes integer value as integer value with decimal, hexadecimal or octal type. 
  • %i behave differently in printf and scanf function of the program.

Examples of %i Format Specifier  :

Let,s see some example for better understanding :

Example 1:

Run
#include<stdio.h>

int main() {
    int val =25;
    printf("The value given is : %i", val);
    return 0;
}

Output :
The value given is : 25

Example 2 :

Run
#include<stdio.h> 

int main() {
    int val =25;
    float val2 = 25.1;
    printf("The value given is : %i\n", val);
    printf("The value given in flaot is : %f", val2);
    return 0;
}

Output :

The value given is : 25
The value given in flaot is : 25.100000

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription

One comment on “%i Format Specifier”