Notification texts go here Contact Us Buy Now!

19 | Print Variables

Print Variables

We use the printf() function to print variables in C programming. We will learn in detail about printing output in later lessons.

For now, let's just see an example to print variables.

#include <stdio.h>
 
int main() {
 
    // create a variable
    int age = 25;
 
    // print the variable
    printf("%d", age);
  
    return 0;
}

Output

25

The printf() function prints anything present inside the quotation marks. However, instead of %d, we are getting 25 (value of the age variable).

This is because, in C, we use format specifiers to print variables. Format specifiers are placeholders that will be replaced by the value of the variable.

Here, %d is a format specifier which is replaced by the value of the age variable (25).

Loading...
The printf() function prints anything present inside the quotation marks. %d is a format specifier which is replaced by the value of variables.
Figure: Print Variables

About the Author

Coding | Riding | Music, Embracing the beauty of code, the thrill of the ride, and the rhythm of life. Let's explore the journey together!

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
Code Copied!