Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Declare a Variable and Print Its Value

    C Programming Examples


    In this tutorial, a basic C program is demonstrated to print the values of predefined variables on the screen as output. The primary aim of this C program is to explain to beginners how to declare variables and print them using the printf() function.

    /* C Program to Declare a Variable and Print Its Value */
    
    #include <stdio.h>
    
    void main ()
    {
      int a = 9, b = 10; /* declaration of integer types variables */
      float c = 5.5, d = 15.5; /* declaration of floating types variables */
    
      printf ("Values of integer variables are: \n");
      printf ("%d\n%d \n", a, b); /* printing integer types of variables using format specifier (%d) */
    
      printf ("Values of floating variables are: \n"); /* printing float types of variables using format specifier (%f) */
      printf ("%f \n%f", c, d);
    }
    

    Program Output:

    Values of integer variables are: 
    9
    10 
    Values of floating variables are: 
    5.500000 
    15.500000


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.