Quick Contact


    Input / Output in C

    The C programming language has the feature of scanf () function, which is used to take the input by the user as per the requirement. The coders also use the printf () function in the programs to display the program’s output.

    Printf () function or Output in C programming language

    The printf () is one of the most common output functions of C programming language, which is used to send the formatted output on the screen.

    Example 1:

    Output in the form of string.

    		#include< stdio.h>
    		int main ()
    		{
    		printf (“Ram is a good boy.”);
    		return 0;
    		}
    	
    Output:
    Ram is a good boy.
    Explanation:
    • All the valid programs must hold the main () function in the C programming language. The execution of a particular code begins from this main () function.
    • The printf () is the library function in C language, which is used to send the screen’s output. This function can also print the string inside the quotations provided by the user.
    • The user needs to include < stdio.h> header file to use printf () function in the particular program.
    • The return statement inside the main () function provides the exit status of the program, which is optional.
    Example 2.

    Output in the form of integer with the help of program.

    		#include< stdio.h>
    		int main ()
    		{
    		int Outputinteger = 3;
    		printf (“Number = %d, Outputinteger”);
    		return 0;
    		}
    	
    Output:
    Number = 3
    Example 3:

    Output in the form of float and double inside the program.

    		#include< stdio.h>
    		int main ()
    		{
    		float x = 15.6;
    		double = 11.9
    		printf (“Number 1= %f\n, x”);
    		printf (“Number 2 =%l f”, y);
    		return 0;
    		}
    	
    Output:
    Number 1 = 15.600000
    Number 2 = 11.900000
    Example 4:

    Output in the form of Character via program of C language.

    		#include< stdio.h>
    		int main ()
    		{
    		Char x = ‘a’;
    		printf (“Character = %c”, x);
    		return 0;
    		}
    	
    Output:
    Character = a
    Scanf () function or input by the user in C programming language

    Scanf () function is the common input function of the C programming language, which is used to take the input from the user as per the requirement. This function can read the formatted input from the standard input, like input given by the keyboard.

    Example:
    		#include< stdio.h>
    		Int main ()
    		{
    		int Outputinteger;
    		printf (“enter the number:”);
    		scanf (“%d”, &Outputinteger);
    		printf (“Number = %d”, Outputinteger);
    		return 0;
    		}
    	
    Output:

    enter the number: 7

    Number = 7

    Copyright 1999- Ducat Creative, All rights reserved.