TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    C Tutorials

    C printf Function

    Overview

    The C printf function is a standard library function. The Standard Input/Output Library contains functions for formatted data transfer in and out of the C program. The two such functions are as follows:

    • printf (print formatted) function
    • scanf (scan formatted) function

    The data printing and reading functions are defined as standard functions which are part of
    the language specification but are not part of the C Language itself. The functions are defined in the system header file stdio.h

    C printf Function

    The printf function formats and displays the arguments on the standard output. By default, it prints the output to the terminal(the standard output device)

    The printf() function prints output to the standard output stream i.e stdout, according to format and other arguments passed to printf().

    Syntax

    The general syntax of the printf function is as below:

    printf(format, arg1,arg2,arg3,…);

    The string format consists of two types of items:

    • Characters that will be printed to the screen
    • conversion specifiers that define how the arguments are displayed.

    Examples

    Print String

    In this example, we will print the string literal to the output screen using the print() function. A string literal is a combination of characters like letters, digits, and other special characters enclosed in double quotation marks. For example, “My name is, John!”

    The print() function call to print the string literal “Hello, World!” is shown below:

    printf(“Hello, World! \n”);

     

    C printf Function

    Note that the printf function will not print the new line. We can achieve this with \n character sequence. The \n is the new line character. This sequence advances the terminal to the left margin of the next line.

    Print Number

    In this example, we will print the number along with string information. The argument number is an integer variable. The format specification %d is for printing in decimal notation.

    For example:

    printf(“The total sum is %d”,number);

    Related Posts

    C Language Characteristics

    C Tutorials /

    C Language Characteristics

    C Source Code .c File

    C Tutorials /

    C Program Files & Formats

    GNU Compiler Collection GCC

    C Tutorials /

    C Compilers

    C Pointers

    C Tutorials /

    C Pointers

    C Tutorials /

    C Two-Dimensional Arrays

    ‹ C Programming Environment› C Variable Initialization

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com