{"id":2239,"date":"2024-05-10T07:16:10","date_gmt":"2024-05-10T07:16:10","guid":{"rendered":"https:\/\/www.skillvertex.com\/blog\/?p=2239"},"modified":"2024-05-10T07:16:10","modified_gmt":"2024-05-10T07:16:10","slug":"formatted-and-unformatted-input-output-functions-in-c-with-examples","status":"publish","type":"post","link":"https:\/\/www.skillvertex.com\/blog\/formatted-and-unformatted-input-output-functions-in-c-with-examples\/","title":{"rendered":"Formatted And Unformatted Input\/Output Functions In C With Examples"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\" id=\"rank-math-toc\"><p>Table of Contents<\/p><nav><ul><li ><a href=\"#formatted-and-unformatted-input-output-functions-in-c-with-examples\">Formatted And Unformatted Input\/Output Functions In C With Examples<\/a><\/li><li ><a href=\"#formatted-io-functions\">Formatted IO Functions<\/a><\/li><li ><a href=\"#why-they-are-called-formatted-i-0-functions\">Why they are called Formatted I\/0 Functions<\/a><\/li><li ><a href=\"#unformatted-input-output-functions\">Unformatted Input\/Output functions<\/a><\/li><li ><a href=\"#formatted-i-o-vs-unformatted-i-o\">Formatted I\/O vs Unformatted I\/O<\/a><\/li><li ><a href=\"#faq-formatted-and-unformatted-input-output-functions-in-c-with-examples\">FAQ- Formatted and Unformatted Input\/Output functions in C with Examples<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"formatted-and-unformatted-input-output-functions-in-c-with-examples\">Formatted And Unformatted Input\/Output Functions In C With Examples<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"formatted-io-functions\">Formatted IO Functions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Formatted I\/O functions are essential for handling user inputs and displaying outputs in a user-friendly way. They enable programmers to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Receive User Inputs:<\/strong> Formatted input functions help programs collect user input in a structured manner. They use format specifiers to interpret and extract specific data types from user input.<\/li>\n\n\n\n<li><strong>Present Data to Users:<\/strong> Formatted output functions allow programs to present data to users in various formats. Format specifiers are used to control how data is displayed, making it more readable and visually appealing.<\/li>\n\n\n\n<li><strong>Support Multiple Data Types:<\/strong> These I\/O functions are versatile and support a wide range of data types, including integers, floating-point numbers, characters, and more. Each data type has corresponding format specifiers for precise formatting.<\/li>\n\n\n\n<li><strong>Formatting Control:<\/strong> Programmers can use format specifiers to control the alignment, width, precision, and other formatting aspects of displayed data, ensuring it&#8217;s presented as intended.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-they-are-called-formatted-i-0-functions\">Why they are called Formatted I\/0 Functions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These functions are called formatted I\/O functions as they can use format specifiers in these functions. Moreover,  we can format these functions according to our needs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are the list of some specifiers<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>NO.<\/strong><\/td><td><strong>Format Specifier &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/td><td><strong>Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/td><td><strong>Description &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/td><\/tr><tr><td>1<\/td><td>%d<\/td><td>int\/signed int<\/td><td>used for I\/O signed integer value<\/td><\/tr><tr><td>2<\/td><td>%c<\/td><td>char<\/td><td>Used for I\/O character value<\/td><\/tr><tr><td>3<\/td><td>%f<\/td><td>float<\/td><td>Used for I\/O decimal floating-point value &nbsp; &nbsp; &nbsp; &nbsp;<\/td><\/tr><tr><td>4<\/td><td>%s<\/td><td>string<\/td><td>Used for I\/O string\/group of characters &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/td><\/tr><tr><td>5<\/td><td>%ld<\/td><td>long int<\/td><td>Used for I\/O long signed integer value<\/td><\/tr><tr><td>6<\/td><td>%u<\/td><td>unsigned int &nbsp;&nbsp;<\/td><td>Used for I\/O unsigned integer value<\/td><\/tr><tr><td>7<\/td><td>%i<\/td><td>unsigned int<\/td><td>used for the I\/O integer value<\/td><\/tr><tr><td>8<\/td><td>%lf<\/td><td>double<\/td><td>Used for I\/O fractional or floating data&nbsp;<\/td><\/tr><tr><td>9<\/td><td>%n<\/td><td>prints<\/td><td>prints nothing&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The following formatted I\/O functions will be discussed in this section-<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>printf()<\/li>\n\n\n\n<li>scanf()<\/li>\n\n\n\n<li>sprintf()<\/li>\n\n\n\n<li>sscanf()<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>printf():<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>printf()<\/code> is a built-in function used to display values like numbers, characters, and strings on the console screen. It&#8217;s pre-defined in the <code>stdio.h<\/code> header, allowing easy output formatting in C programs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax 1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf(\u201cFormat Specifier\u201d, var1, var2, \u2026., varn);  \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ printf() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    \/\/ Declaring an int type variable\n    int a;\n  \n    \/\/ Assigning a value in a variable\n    a = 20;\n  \n    \/\/ Printing the value of a variable\n    printf(\"%d\", a);\n  \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>20\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax 2: &nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf(\u201cEnter the text which you want to display\u201d);\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ printf() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    \/\/ Displays the string written\n    \/\/ inside the double quotes\n    printf(\"This is a string\");\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>This is a string\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. <strong>scanf():<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>scanf():<\/strong> In C, <code>scanf()<\/code> is a built-in function for reading user input from the keyboard. It can read values of various data types like integers, floats, characters, and strings. <code>scanf()<\/code> is a pre-defined function declared in the <code>stdio.h<\/code> header file. It uses the <code>&amp;<\/code> (address-of operator) to store user input in the memory location of a variable.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scanf(\u201cFormat Specifier\u201d, &amp;var1, &amp;var2, \u2026., &amp;varn);  \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ scanf() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    int num1;\n  \n    \/\/ Printing a message on\n    \/\/ the output screen\n    printf(\"Enter a integer number: \");\n  \n    \/\/ Taking an integer value\n    \/\/ from keyboard\n    scanf(\"%d\", &amp;num1);\n  \n    \/\/ Displaying the entered value\n    printf(\"You have entered %d\", num1);\n  \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a integer number: You have entered 0\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a integer number: 56\nYou have entered 56<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. <strong>sprintf():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>sprintf():<\/strong> Short for &#8220;string print,&#8221; <code>sprintf()<\/code> is similar to <code>printf()<\/code> but it stores the formatted string into a character array instead of displaying it on the console screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the sprintf() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    char str&#91;50];\n    int a = 2, b = 8;\n  \n    \/\/ The string \"2 and 8 are even number\"\n    \/\/ is now stored into str\n    sprintf(str, \"%d and %d are even number\",\n            a, b);\n  \n    \/\/ Displays the string\n    printf(\"%s\", str);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2 and 8 are even number\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. <strong>sscanf():<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>sscanf():<\/strong> Abbreviated for &#8220;string scanf,&#8221; <code>sscanf()<\/code> resembles <code>scanf()<\/code> but reads data from a string or character array rather than from the console screen.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sscanf(array_name, \u201cformat specifier\u201d, &amp;variable_name);\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ sscanf() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    char str&#91;50];\n    int a = 2, b = 8, c, d;\n  \n    \/\/ The string \"a = 2 and b = 8\"\n    \/\/ is now stored into str\n    \/\/ character array\n    sprintf(str, \"a = %d and b = %d\",\n            a, b);\n  \n    \/\/ The value of a and b is now in\n    \/\/ c and d\n    sscanf(str, \"a = %d and b = %d\",\n           &amp;c, &amp;d);\n  \n    \/\/ Displays the value of c and d\n    printf(\"c = %d and d = %d\", c, d);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>c = 2 and d = 8\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"unformatted-input-output-functions\">Unformatted Input\/Output functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Unformatted I\/O Functions:<\/strong> These functions are used exclusively for character data types or character arrays\/strings. They are designed for reading single inputs from the user at the console and for displaying values on the console.<\/li>\n\n\n\n<li><strong>Why &#8220;Unformatted&#8221;?:<\/strong> They are referred to as &#8220;unformatted&#8221; I\/O functions because they do not support format specifiers. Unlike formatted I\/O functions like <code>printf()<\/code> and <code>scanf()<\/code>, you cannot use format specifiers to control the formatting of the data. They display or read data as-is without formatting options.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The following are unformatted I\/O functions<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>getch()<\/li>\n\n\n\n<li>getche()<\/li>\n\n\n\n<li>getchar()<\/li>\n\n\n\n<li>putchar()<\/li>\n\n\n\n<li>gets()<\/li>\n\n\n\n<li>puts()<\/li>\n\n\n\n<li>putch()<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>getch():<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>getch():<\/strong> In C, <code>getch()<\/code> reads a single character from the keyboard without displaying it on the console screen. It immediately returns without requiring the user to press the Enter key. This function is declared in the <code>conio.h<\/code> header file and is often used for controlling screen display.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getch(); \n\nor \n\nvariable-name = getch();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ getch() function\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    printf(\"Enter any character: \");\n  \n    \/\/ Reads a character but\n    \/\/ not displays\n    getch();\n  \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any character: \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. <strong>getche():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>getche()<\/code> reads a single character from the keyboard, displays it on the console screen, and immediately returns without requiring the user to press the Enter key. This function is declared in the <code>conio.h<\/code> header file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getche(); \n\nor \n\nvariable_name = getche();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the getche() function\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    printf(\"Enter any character: \");\n  \n    \/\/ Reads a character and\n    \/\/ displays immediately\n    getche();\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any character: g\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. <strong>getchar():&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>getchar()<\/code> reads a single character from the keyboard and waits until the Enter key is pressed. It processes one character at a time. This function is declared in the <code>stdio.h<\/code> header file<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Variable-name = getchar();\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/ C program to implement\n\/\/ the getchar() function\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    \/\/ Declaring a char type variable\n    char ch;\n  \n    printf(\"Enter the character: \");\n  \n    \/\/ Taking a character from keyboard\n    ch = getchar();\n  \n    \/\/ Displays the value of ch\n    printf(\"%c\", ch);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter the character: a\n\na<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. <strong>putchar():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>putchar()<\/code> is used to display a single character at a time, either by passing the character directly or by using a variable that stores the character. This function is declared in the <code>stdio.h<\/code> header file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>putchar(variable_name);  \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the putchar() function\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    char ch;\n    printf(\"Enter any character: \");\n  \n    \/\/ Reads a character\n    ch = getchar();\n  \n    \/\/ Displays that character\n    putchar(ch);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any character: Z\n\nZ<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. <strong>gets():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>gets()<\/code> reads a group of characters or strings from the keyboard, and these characters are stored in a character array. It allows you to input space-separated texts or strings. This function is declared in the <code>stdio.h<\/code> header file. However, please note that <code>gets()<\/code> is considered unsafe due to the risk of buffer overflow and is generally discouraged in favor of safer alternatives like <code>fgets()<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>char str&#91;length of string in number]; \/\/Declare a char type variable of any length \n\ngets(str); <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the gets() function\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    \/\/ Declaring a char type array\n    \/\/ of length 50 characters\n    char name&#91;50];\n  \n    printf(\"Please enter some texts: \");\n  \n    \/\/ Reading a line of character or\n    \/\/ a string\n    gets(name);\n  \n    \/\/ Displaying this line of character\n    \/\/ or a string\n    printf(\"You have entered: %s\",\n           name);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Please enter some texts: Skill Vertex\n\nYou have entered: Skill Vertex<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">6. <strong>puts():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C programming, <code>puts()<\/code> is used to display a group of characters or strings that are already stored in a character array. This function is declared in the <code>stdio.h<\/code> header file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> puts(identifier_name );\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the puts() function\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    char name&#91;50];\n    printf(\"Enter your text: \");\n  \n    \/\/ Reads string from user\n    gets(name);\n  \n    printf(\"Your text is: \");\n  \n    \/\/ Displays string\n    puts(name);\n  \n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter your text: Skill Vertex\n\nYour text is: Skill Vertex<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">7. <strong>putch():<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In C, <code>putch()<\/code> is used to display a single character provided by the user, and it prints the character at the current cursor location. This function is declared in the <code>conio.h<\/code> header file<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>putch(variable_name);  \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C program to implement\n\/\/ the putch() functions\n#include &lt;conio.h&gt;\n#include &lt;stdio.h&gt;\n  \n\/\/ Driver code\nint main()\n{\n    char ch;\n    printf(\"Enter any character:\\n \");\n  \n    \/\/ Reads a character from the keyboard\n    ch = getch();\n  \n    printf(\"\\nEntered character is: \");\n  \n    \/\/ Displays that character on the console\n    putch(ch);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any character:\n\nEntered character is: d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"formatted-i-o-vs-unformatted-i-o\">Formatted I\/O vs Unformatted I\/O<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>S No.<\/strong><\/td><td><strong>Formatted I\/O functions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/td><td><strong>Unformatted I\/O functions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/strong><\/td><\/tr><tr><td>1<\/td><td>These Formatted I\/O functions will provide input or display output in the user\u2019s desired format.<\/td><td>Whereas, Unformatted I\/O functions won&#8217;t allow to take input or display output in user desired format.<\/td><\/tr><tr><td>2<\/td><td>They will  support format specifiers.<\/td><td>They will support format specifiers.<\/td><\/tr><tr><td>3<\/td><td>These will store  data more user-friendly<\/td><td>These functions are notuser-friendly.<\/td><\/tr><tr><td>4<\/td><td>In Formatted I\/0 Functions, we can use all data types.<\/td><td>These functions are not user-friendly.<\/td><\/tr><tr><td>5<\/td><td>Examples -printf(), scanf, sprintf() and sscanf()<\/td><td>Example-getch(), getche(), gets() and puts()<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq-formatted-and-unformatted-input-output-functions-in-c-with-examples\">FAQ- Formatted and Unformatted Input\/Output functions in C with Examples<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1695990928737\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q1. What is an example of formatted input output statement?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. Interactive Input<\/p>\n<p>Example: int age; double gpa; char answer; printf(&#8220;Please enter your age: &#8220;); scanf(&#8220;%d&#8221;, &amp;age); printf(&#8220;Please enter your gpa: &#8220;); scanf(&#8220;%lf&#8221;, %gpa); printf(&#8220;Do you like pie (Y\/N)? &#8220;); scanf(&#8220;%c&#8221;, %answer);<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1695990937570\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q2. Which are the types of formatted input and output?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. %d. Integer: int\/ signed int. Used to read and print integer values.<br \/>%c. Character: char. Used to read and print Character values.<br \/>%f. Floating point: float. Used to read and print decimal values.<br \/>%s. String.<br \/>%ld. long int.<br \/>% you. Unsigned int. <br \/>%i. Unsigned int.<br \/>%lf. double.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1695990947353\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q3. What is formatted input output functions in C with example?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. Formatted I\/O functions are used in programming to handle input from users and display information in different formats. These functions support various data types like integers, floating-point numbers, and characters, and they use format specifiers to control how data is presented to users.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Formatted And Unformatted Input\/Output Functions In C With Examples Formatted IO Functions Formatted I\/O functions are essential for handling user inputs and displaying outputs in a user-friendly way. They enable programmers to: Why they are called Formatted I\/0 Functions These functions are called formatted I\/O functions as they can use format specifiers in these functions. &#8230; <a title=\"Formatted And Unformatted Input\/Output Functions In C With Examples\" class=\"read-more\" href=\"https:\/\/www.skillvertex.com\/blog\/formatted-and-unformatted-input-output-functions-in-c-with-examples\/\" aria-label=\"More on Formatted And Unformatted Input\/Output Functions In C With Examples\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":2241,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[398],"class_list":["post-2239","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-formatted-and-unformatted-input-output-functions-in-c-with-examples","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"_links":{"self":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/comments?post=2239"}],"version-history":[{"count":13,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2239\/revisions"}],"predecessor-version":[{"id":10641,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/2239\/revisions\/10641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media\/2241"}],"wp:attachment":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media?parent=2239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/categories?post=2239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/tags?post=2239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}