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 Variable Initialization

    Overview

    In this tutorial, we will learn about C variable initialization with some examples. We can initialize a C variable at the same time when we declare it. We can declare and initialize a variable using a single programming statement in C.

    Variable Initialization

    Storing the first valve in the variable(i.e into the memory location)  is called variable initialization. The first value is called the initializer. Note that the variable can change its value during the course of the program.

    Syntax

    The general syntax to initialize a variable is as follows:

    <data_type> <variable_name> = <value> ;

    The = symbol is the assignment operator.

    Examples

    int number = 20;

    In this example, we have declared an integer variable number and initialized the variable with the value 20.

     

    C Variable Initialization

    Let’s look at another example. In this example, we have declared a double precision floating point number variable interestRate and initialized the variable with the value 0.15

    double interestRate = 0.15;

     

    C Variable Declaration and Initialization

     

    When a variable is defined, it usually contains the default value or it
    may contain a garbage value. It is important to initialize the variable and store data before accessing the variable value. This is a safe programming technique to avoid unexpected program results.

    —

    C Tutorials

    C Tutorials on this website can be found at:

    https://www.testingdocs.com/c-language-tutorial/

    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 printf Function› Compile and Execute C Program

    Recent Posts

    • Running Tests in Parallel with Selenium Grid
    • Advanced Selenium Features
    • Locating Web Elements
    • Running the Test Script
    • Writing Your First Selenium Test Script
    • Getting Started with Selenium Automation Testing
    • Setting Up the Environment
    • How can you monitor the Quality Assurance Audit?
    • Leveraging LambdaTest with Appium 2.0
    • Appium 2.0 Plugins ListAppium 2.0 Plugins
    • Touch Actions and Multi-Touch Actions
    • Changes in Drivers and Classes
    • Appium Inspector
    • Capabilities in Appium 2.0
    • Appium 2.0 Driver ListAppium 2.0 Driver Installation & Management
    CyberLink Multimedia Software

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com